Rust 各版本更新要点

作者: 人间正道是数学 | 来源:发表于2018-01-15 19:25 被阅读306次

    本文将汇总Rust 1.0之后各版本在语法和部分库函数方面的更新,略过编译器和标准库的性能优化、工具链和文档的改进等内容。

    2015-05-15 Rust 1.0

    2015-06-25 Rust 1.1

    • New std::fs APIs.

    2015-08-06 Rust 1.2

    • Rc<[T]> is fully usable.

    2015-09-17 Rust 1.3

    • new Duration API and enhancements to Error and Hash/Hasher.
    • 'static variables may now be recursive.

    2015-10-29 Rust 1.4

    • When reading ‘lines’ to treat both \n and \r\n as a valid line-ending.

    2015-12-10 Rust 1.5

    2016-01-21 Rust 1.6

    • The core library is stable, as are most of its APIs. Rust’s standard library is two-tiered: there’s a small core library, libcore, and the full standard library, libstd, that builds on top of it. libcore is completely platform agnostic, and requires only a handful of external symbols to be defined. Rust’s libstd builds on top of libcore, adding support for memory allocation, I/O, and concurrency. Applications using Rust in the embedded space, as well as those writing operating systems, often eschew libstd, using only libcore.
    • The `#[图片上传失败...(image-f4d162-1516015456023)].

    2016-03-02 Rust 1.7

    • support for custom hash algorithms in the standard library’s HashMap<K, V> type.

    2016-04-14 Rust 1.8

    • “operator equals” operators, such as += and -=, are now overloadable via coresponding traits.

    • struct with no fields can have curly braces:

      struct Foo; // works
      struct Bar { } // also works
      

    2016-05-26 Rust 1.9

    • The #[deprecated] attribute when applied to an API will generate warnings when used. The warnings may be suppressed with#[allow(deprecated)].
    • stabilization of the std::panic module.

    2016-07-07 Rust 1.10

    2016-08-18 Rust 1.11

    2016-09-29 Rust 1.12

    2016-11-10 Rust 1.13

    • new operator, ?, for error handling, a solid ergonomic improvement to the old try! macro.
    fn read_username_from_file() -> Result<String, io::Error> {
        let mut f = File::open("username.txt")?;
        let mut s = String::new();
    
        f.read_to_string(&mut s)?;
    
        Ok(s)
    }
    
    • Macros can now be used in type position (RFC 873).

    • Attributes can be applied to statements (RFC 16).

    2016-12-22 Rust 1.14

    2017-02-02 Rust 1.15

    2017-03-16 Rust 1.16

    2017-04-27 Rust 1.17

    2017-06-08 Rust 1.18

    2017-07-20 Rust 1.19

    2017-08-31 Rust 1.20

    • Define “associated constants” on traits, structs, and enums.

      struct Struct;
      
      impl Struct {
        // associated constant
        const ID: u32 = 0;
        
        // associated function
          fn foo() {
              println!("foo is called");
          }
      }
      
      fn main() {
          Struct::foo();
          println!("the ID of Struct is: {}", Struct::ID);
      }
      
    • allow messages in the unimplemented!() macro. ie. unimplemented!("Waiting for 1.21 to be stable")

    • Upgrade to Unicode 10.0.0

    2017-10-12 Rust 1.21

    (0..10).for_each(|i| println!("{}", i));
    

    2017-11-22 Rust 1.22

    2018-01-04 Rust 1.23

    • AsciiExt methods are now defined directly on u8, char, [u8], and str types, so you no longer need to import the trait.
    • The various std::sync::atomic types now implement From their non-atomic types.

    相关文章

      网友评论

        本文标题:Rust 各版本更新要点

        本文链接:https://www.haomeiwen.com/subject/xsidoxtx.html