We are pleased to announce the third edition of the Rust language, Rust 2021, which will be released in October. Rust 2021 contains a few small changes that will nevertheless significantly improve the usability of Rust.
What is the Editorial Board?
The Rust 1.0 release established "stability without stagnation" as a basic rule of Rust. Since the 1.0 release, the rule has been that by releasing a feature in a stable version, we commit to supporting it in all future releases.
However, there are times when the ability to make small changes to the language can be useful - even if they don't have backward compatibility. The most obvious example is the introduction of a new keyword that invalidates variables with the same name. For example, in the first version of Rust, there were no keywords async
and await
. Suddenly changing these words to keywords in later versions would cause, for example, the code to let async = 1;
stop working.
Revisions are the mechanism we use to address this issue. When we want to release a feature without backward compatibility, we make it part of the new Rust edition . Revisions are optional and must be written explicitly, so existing packages do not see these changes until they explicitly upgrade to the new version. This means that even the latest version of Rust will still not be considered async
a keyword unless 2018 or later is selected. This choice is made for each package Cargo.toml
. New packages created cargo new
are always set to use the latest stable release.
Editorials don't share the ecosystem
: . , .
, . , , "". Rust, , .
β . , . , . , Rust 2018 , async
, : r#async
.
: . , .
, . , , . , , . , , , .
Rust 2021?
Rust 2021 , . . , . -, () Rust. -, , , .
β , , . , Option
, Vec
, drop
Clone
.
Rust , , . , - . , example
, pub struct Option;
, use example::*;
Option
example
.
. x.try_into()
MyTryInto
, TryInto
std
, . TryInto
β .
Rust 2021 . , :
Cargo
Rust 1.51.0, Cargo resolver = "2"
Cargo.toml
.
Rust 2021 . edition = "2021"
Cargo.toml
resolver = "2"
.
, . Rust 1.51.
IntoIterator
Rust 1.53 IntoIterator
. , &[1, 2, 3]
&mut [1, 2, 3]
, [1, 2, 3]
.
for &e in &[1, 2, 3] {} // Ok :)
for e in [1, 2, 3] {} // :(
, , . . array.into_iter()
, (&array).into_iter()
- . .
( ) "" . .
" IntoIterator
Rust 2021". : , .
, Rust 1.53.0. , Rust 2021. Rust 2015 2018 - array.into_iter()
(&array).into_iter()
, . .into_iter()
, for e in [1, 2, 3]
, iter.zip([1, 2, 3])
. .
, , , . , .
, . , || a.x + 1
a
a.x
. . () , , , .
let a = SomeStruct::new();
drop(a.x); //
println!("{}", a.y); // :
let c = || println!("{}", a.y); // : `a`
c();
Rust 2021, , . Rust 2021.
, , . β . , . let _ = &a;
, , .
panic!()
β Rust. , β - .
panic!("{}", 1); // , "1"
panic!("{}"); // , "{}"
panic!()
, . .
let a = "{";
println!(a); // :
panic!(a); // : panic
( , panic!(123)
, , , ).
. println!("hello {name}")
println!("hello {}", name)
. panic!("hello {name}")
, panic!()
.
, Rust 2021 β panic!()
. panic!()
. β println!()
β . panic!()
, panic_any()
- .
, core::panic!()
std::panic!()
Rust 2021. , #![no_std]
.
, : prefix#identifier
, prefix"string"
, prefix'c'
prefix#123
, prefix
( , β , b'...'
r"..."
).
, hello"world"
, : hello
"world"
. () β : hello "world"
.
, RFC . , β β .
, :
f""
. ,f"hello {name}"
format_args!()
.c""
z""
- .k#keyword
, , . ,async
2015,k#async
2015, 2018,async
.
Rust 2021. .
bare-trait-objects
βdyn
- Rust 2021.ellipsis-inclusive-range-patterns
β...
Rust 2021...=
, .
"" macro_rules
Rust 1.53.0 |
, . Some(1 | 2)
Some(1) | Some(2)
. , .
macro_rules
. :pat
. :pat
|
, Rust 1.53 ( ) |
. , A | B
, matches!()
, - $($_:pat)|+
. , , :pat
Rust 1.53.0, |
.
Rust 2021. :pat
A | B
, - |
, :pat_param
. : .
?
, , 2021 Rust 1.56.0. Rust 1.56.0 - , 21 .
, Rust β , . , Rust, , . , , , .
, , . , Rust 2021!
. , .
, Nightly, -Zunstable-options --edition=2021
.
Rust - . , .
OpenCollective.
fan-tom, blandger, Belanchuk, TelegaOvoshey andreevlex.