




















The Rust team is happy to announce a new version of Rust, 1.77.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.77.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.77.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!
This release is relatively minor, but as always, even incremental improvements lead to a greater whole. A few of those changes are highlighted in this post, and others may yet fill more niche needs.
Rust now supports C-string literals (c"abc") which expand to a nul-byte
terminated string in memory of type &'static CStr. This makes it easier to write code
interoperating with foreign language interfaces which require nul-terminated
strings, with all of the relevant error checking (e.g., lack of interior nul
byte) performed at compile time.
async fnAsync functions previously could not call themselves due to a compiler limitation. In 1.77, that limitation has been lifted, so recursive calls are permitted so long as they use some form of indirection to avoid an infinite size for the state of the function.
This means that code like this now works:
async fn fib(n: u32) -> u32 {
match n {
0 | 1 => 1,
_ => Box::pin(fib(n-1)).await + Box::pin(fib(n-2)).await
}
}offset_of!1.77.0 stabilizes offset_of! for struct fields, which provides access to the
byte offset of the relevant public field of a struct. This macro is most useful
when the offset of a field is required without an existing instance of a type.
Implementing such a macro is already possible on stable, but without an
instance of the type the implementation would require tricky unsafe code which
makes it easy to accidentally introduce undefined behavior.
Users can now access the offset of a public field with offset_of!(StructName, field). This expands to a usize expression with the offset in bytes from the
start of the struct.
Cargo profiles
which do not enable debuginfo in
outputs (e.g., debug = 0) will enable strip = "debuginfo" by default.
This is primarily needed because the (precompiled) standard library ships with debuginfo, which means that statically linked results would include the debuginfo from the standard library even if the local compilations didn't explicitly request debuginfo.
Users which do want debuginfo can explicitly enable it with the debug flag in the relevant Cargo profile.
array::each_refarray::each_mutcore::netf32::round_ties_evenf64::round_ties_evenmem::offset_of!slice::first_chunkslice::first_chunk_mutslice::split_first_chunkslice::split_first_chunk_mutslice::last_chunkslice::last_chunk_mutslice::split_last_chunkslice::split_last_chunk_mutslice::chunk_byslice::chunk_by_mutBound::mapFile::create_newMutex::clear_poisonRwLock::clear_poisonCheck out everything that changed in Rust, Cargo, and Clippy.
Many people came together to create Rust 1.77.0. We couldn't have done it without all of you. Thanks!
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。