

























The Rust team is happy to announce a new version of Rust, 1.79.0. Rust is a programming language empowering everyone to build reliable and efficient software.
If you have a previous version of Rust installed via rustup, you can get 1.79.0 with:
$ rustup update stable
If you don't have it already, you can get rustup from the appropriate page on our website, and check out the detailed release notes for 1.79.0.
If you'd like to help us out by testing future releases, you might consider updating locally to use the beta channel (rustup default beta) or the nightly channel (rustup default nightly). Please report any bugs you might come across!
const expressionsconst { ... } blocks are now stable in expression position, permitting
explicitly entering a const context without requiring extra declarations (e.g.,
defining const items or associated constants on a trait).
Unlike const items (const ITEM: ... = ...), inline consts are able to make
use of in-scope generics, and have their type inferred rather than written explicitly, making them particularly useful for inline code snippets. For example, a pattern like:
const EMPTY: Option<Vec<u8>> = None;
let foo = [EMPTY; 100];
can now be written like this:
let foo = [const { None }; 100];
Notably, this is also true of generic contexts, where previously a verbose trait declaration with an associated constant would be required:
fn create_none_array<T, const N: usize>() -> [Option<T>; N] {
[const { None::<T> }; N]
}
This makes this code much more succinct and easier to read.
See the reference documentation for details.
Rust 1.79 stabilizes the associated item bounds syntax, which allows us to put
bounds in associated type position within other bounds, i.e.
T: Trait<Assoc: Bounds...>. This avoids the need to provide an extra,
explicit generic type just to constrain the associated type.
This feature allows specifying bounds in a few places that previously either were not possible or imposed extra, unnecessary constraints on usage:
where clauses - in this position, this is equivalent to breaking up the bound into two (or more) where clauses. For example, where T: Trait<Assoc: Bound> is equivalent to where T: Trait, <T as Trait>::Assoc: Bound.trait CopyIterator: Iterator<Item: Copy> {}.trait Trait { type Assoc: Trait2<Assoc2: Copy>; }.impl Iterator<Item: Copy> defines an iterator whose item is Copy without having to actually name that item bound.See the stabilization report for more details.
Temporaries which are immediately referenced in construction are now
automatically lifetime extended in match and if constructs. This has the
same behavior as lifetime extension for temporaries in block constructs.
For example:
let a = if true {
..;
&temp() // used to error, but now gets lifetime extended
} else {
..;
&temp() // used to error, but now gets lifetime extended
};
and
let a = match () {
_ => {
..;
&temp() // used to error, but now gets lifetime extended
}
};
are now consistent with prior behavior:
let a = {
..;
&temp() // lifetime is extended
};
This behavior is backwards compatible since these programs used to fail compilation.
The standard library distributed by the Rust project is now compiled with
-Cforce-frame-pointers=yes, enabling downstream users to more easily profile
their programs. Note that the standard library also continues to come up with
line-level debug info (e.g., DWARF), though that is stripped by default in Cargo's release profiles.
{integer}::unchecked_add{integer}::unchecked_mul{integer}::unchecked_sub<[T]>::split_at_unchecked<[T]>::split_at_mut_unchecked<[u8]>::utf8_chunksstr::Utf8Chunksstr::Utf8Chunk<*const T>::is_aligned<*mut T>::is_alignedNonNull::is_aligned<*const [T]>::len<*mut [T]>::len<*const [T]>::is_empty<*mut [T]>::is_emptyNonNull::<[T]>::is_emptyCStr::count_bytesio::Error::downcastnum::NonZero<T>path::absoluteproc_macro::Literal::byte_characterproc_macro::Literal::c_stringThese APIs are now stable in const contexts:
Atomic*::into_innerio::Cursor::newio::Cursor::get_refio::Cursor::positionio::emptyio::repeatio::sinkpanic::Location::callerpanic::Location::filepanic::Location::linepanic::Location::columnCheck out everything that changed in Rust, Cargo, and Clippy.
Many people came together to create Rust 1.79.0. We couldn't have done it without all of you. Thanks!
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。