云网牛站
所在位置:首页 > Linux新闻 > Rust 2018将要发布:帮助从Rust 2015过渡

Rust 2018将要发布:帮助从Rust 2015过渡

2018-08-21 09:38:43作者:linux人稿源:开源社区

Rust 核心开发团队发表报告称下一代 Rust 2018 首个版本将在 2018 年 12 月 6 日准备妥当,它对应 Rust 1.31,在8月初时已发布了 Rust 1.28。新版本在新标签下整合了自 Rust 2015 首次发布以来的大量新功能,进一步丰富了语言特性。

Rust 2018 将重点放在语言生产力的提升上,如,关注编译器性能,优化语言特性,进一步改进工具、库和文档等。Rust 2018 的部分语言新特性已在最近的 Rust 发布说明中公布,可能会出现在 Rust 1.31 正式版之前的版本中,其中包括:impl Trait、macros 2.0、SIMD 支持,生成器,非词汇生命周期(non-lexical lifetimes),async/await 支持和模块改造。

最值得注意的是,Rust 2018 将在一定程度上放松其稳定性保证,为可能破坏现有 Rust 2015 代码的语言更改提供支持。例如,Rust 2018 将包含 try 关键字,这可能与某些代码中的函数或变量名称冲突。

 

为了解决这个问题和其他类似可能出现的问题,并帮助开发者从 Rust 2015 过渡到 Rust 2018,Rust 将遵循 C++ 和 Java 的步骤,这包含如下几个含义:

1.Rust 2018 可选择加入。 如果要在现有项目中使用 Rust 2018,可以将 edition='2018' 添加到项目 cargo.toml 中。 如果缺少版本密钥,Rust 编译器将默认使用 Rust 2015.。使用 cargo new 创建的所有新项目默认都加入 edition='2018'。

2.由于 Rust 编译器将能够同时支持 Rust 2015 和 2018,因此 Rust 2015 和 Rust 2018 的项目依赖和版本可以任意混合使用,而不会出现问题。 这也就是说,您将可以在 Rust 2018 程序中使用 Rust 2015 依赖项,也可以在 Rust 2015 项目中使用 Rust 2018 依赖项。

3.语言核心将保持不变,这意味着 Rust 2018 将仅包括表层的更改,例如前面提到的 try 关键字,或一些警告转换为错误等。

 

此外,Rust 2018 将包括一个新的工具 cargo fix,它将帮助开发人员转换现有的代码库,实现代码的逐步转换,以采用 Rust 2018 推荐的新功能和习惯用法。

Rust 核心团队8月初发布了 Rust 1.28,引入了全局分配器,允许开发人员提供自己的内存分配器来代替系统分配器;NonZero 数字类型,可以进行内存优化;改进的错误消息和格式。

 

rust项目地址

 

附:Building from Source Building on *nix

1.Make sure you have installed the dependencies:

g++ 4.7 or later or clang++ 3.x or later

python 2.7 (but not 3.x)

GNU make 3.81 or later

cmake 3.4.3 or later

curl

git

2.Clone the source with git:

$ git clone https://github.com/rust-lang/rust.git

$ cd rust

3.Build and install:

$ git submodule update --init --recursive --progress

$ ./x.py build && sudo ./x.py install

Note: Install locations can be adjusted by copying the config file from ./config.toml.example to ./config.toml, and adjusting the prefix option under [install]. Various other options, such as enabling debug information, are also supported, and are documented in the config file.

When complete, sudo ./x.py install will place several programs into /usr/local/bin: rustc, the Rust compiler, and rustdoc, the API-documentation tool. This install does not include Cargo, Rust's package manager, which you may also want to build.

 

相关主题

Ubuntu 18.04下gcc、g++不同版本的安装与转换

精选文章
热门文章