The release of the System Programming Language Rust 1.56, based on the Mozilla project, but now developed under the patronage of an independent non-profit organization RUST FOUNDATION. In addition to the standard version of the version, the release is also indicated as RUST 2021 and marks the stabilization of the changes proposed over the past three years. RUST 2021 will also be the basis for increasing the functionality in the next three years, by analogy with how the release of the Rust 2018 became a basis for the development of the language in the past three years.
To preserve compatibility, developers can use in their programs “2015”, “2018” and “2021”, allowing to bind programs to sections of a language status corresponding to the selected editions of Rust. The editors were introduced to separate incompatible changes and configured in the CARGO packet metadata through the “Edition” field in the [Package] section. For example, the 2018 editorial office includes functionality stabilized at the end of 2018 and also covers all further changes that do not violate compatibility. The editorial office of “2021” additionally includes violating innovation compatibility proposed in the current release of 1.56 and approved for implementation in the future. In addition to the language itself, the state of the toolkit and documentation also take into account.
Basic incompatibility recorded in Rust 2021:
- Separate gripping in short circuits can now capture individual names of the fields instead of the entire identifier. For example, “|| a.x + 1” will capture only “a.x” instead of “a”.
- Intoiterator type: array.into_iter () allows you to organize a crosspower of an array elements by values, and not by reference.
- in macro_rules changed the processing of expressions “|” (OR Logic Operation) In templates – the “: PAT” specifier in comparables now takes into account the templates “A | B”.
- in the Cargo batch manager is enabled by default the second version of the feature of the available features (Feature Resolver), the support of which appeared in Rust 1.51.
- Tryfrom, Tryinto and Fromiterator are added to the Prelude standard library module.
- Macros Panic! (..) and Assert! (Expr, ..) Now always use Format_Args! (..) To format strings by analogy with println! ().
- In the syntax of the language reserved Ident #, Ident expressions … “and Ident ‘…’.
- Bare_trait_Objects and Ellipsis_InClusive_Range_Patterns warnings are translated into error category.
innovations rust 1.56:
- in cargo.toml in the “[PACKAGE] section” The rust-version field has been added through which you can define the minimum supported version of Rust for the CRATE-package. If the current version does not match the specified CARGO parameter stops working with error output.
- When mapping with a sample using the “Binding @ Pattern” expressions, support is implemented to specify additional bindings (for example, “Let Matrix @ Matrix {Row_len, ..} = get_matrix ();”).
- In the category of stable, a new portion of the API is translated, including stabilized methods and implementations of the type:
- std :: OS :: UNIX :: FS :: Chroot
- Unsafecell :: Raw_get
- bufwriter :: inte_parts
- Core :: Panic :: {unwindsafe, refunwindsafe, assertunwindsafe}
- vec :: shrink_to
- string :: shrink_to
- osstring :: shrink_to