1.51.0 #
- Released on: 25 March, 2021
- Branched from master on: 5 February, 2021
Language #
- You can now parameterize items such as functions, traits, and
struct
s by constant values in addition to by types and lifetimes. Also known as “const generics” E.g. you can now write the following. Note: Only values of primitive integers,bool
, orchar
types are currently permitted.struct GenericArray<T, const LENGTH: usize> { inner: [T; LENGTH] } impl<T, const LENGTH: usize> GenericArray<T, LENGTH> { const fn last(&self) -> Option<&T> { if LENGTH == 0 { None } else { Some(&self.inner[LENGTH - 1]) } } }
Compiler #
- Added the
-Csplit-debuginfo
codegen option for macOS platforms. This option controls whether debug information is split across multiple files or packed into a single file. Note This option is unstable on other platforms. - Added tier 3* support for
aarch64_be-unknown-linux-gnu
,aarch64-unknown-linux-gnu_ilp32
, andaarch64_be-unknown-linux-gnu_ilp32
targets. - Added tier 3 support for
i386-unknown-linux-gnu
andi486-unknown-linux-gnu
targets. - The
target-cpu=native
option will now detect individual features of CPUs.
* Refer to Rust’s [platform support page][platform-support-doc] for more information on Rust’s tiered platform support.
Libraries #
Box::downcast
is now also implemented for anydyn Any + Send + Sync
object.str
now implementsAsMut<str>
.u64
andu128
now implementFrom<char>
.Error
is now implemented for&T
whereT
implementsError
.Poll::{map_ok, map_err}
are now implemented forPoll<Option<Result<T, E>>>
.unsigned_abs
is now implemented for all signed integer types.io::Empty
now implementsio::Seek
.rc::Weak<T>
andsync::Weak<T>
’s methods such asas_ptr
are now implemented forT: ?Sized
types.Div
andRem
by theirNonZero
variant is now implemented for all unsigned integers.
Stabilized APIs #
Arc::decrement_strong_count
Arc::increment_strong_count
Once::call_once_force
Peekable::next_if_eq
Peekable::next_if
Seek::stream_position
array::IntoIter
panic::panic_any
ptr::addr_of!
ptr::addr_of_mut!
slice::fill_with
slice::split_inclusive_mut
slice::split_inclusive
slice::strip_prefix
slice::strip_suffix
str::split_inclusive
sync::OnceState
task::Wake
VecDeque::range
VecDeque::range_mut
Cargo #
- Added the
split-debuginfo
profile option to control the -Csplit-debuginfo codegen option. - Added the
resolver
field toCargo.toml
to enable the new feature resolver and CLI option behavior. Version 2 of the feature resolver will try to avoid unifying features of dependencies where that unification could be unwanted. Such as using the same dependency with astd
feature in a build scripts and proc-macros, while using theno-std
feature in the final binary. See the Cargo book documentation for more information on the feature.
Rustdoc #
- Rustdoc will now include documentation for methods available from nested
Deref
traits. - You can now provide a
--default-theme
flag which sets the default theme to use for documentation.
Various improvements to intra-doc links:
- You can link to non-path primitives such as
slice
. - You can link to associated items.
- You can now include generic parameters when linking to items, like
Vec<T>
.
Misc #
Compatibility Notes #
- WASI platforms no longer use the
wasm-bindgen
ABI, and instead use the wasm32 ABI. rustc
no longer promotes division, modulo and indexing operations toconst
that could fail.- The minimum version of glibc for the following platforms has been bumped to version 2.31
for the distributed artifacts.
armv5te-unknown-linux-gnueabi
sparc64-unknown-linux-gnu
thumbv7neon-unknown-linux-gnueabihf
armv7-unknown-linux-gnueabi
x86_64-unknown-linux-gnux32
atomic::spin_loop_hint
has been deprecated. It’s recommended to usehint::spin_loop
instead.