Series: The Rust Annals
Vol. I Issue 77 nlopes.dev
Announcing Rust 1.76.0
Rust 1.76 is a relatively minor release whose principal changes clarify function-signature ABI compatibility and make runtime type descriptions easier to obtain for unnameable and opaque types. It also stabilizes inspection, pointer, hashing, and shared-ownership APIs.
Function-call ABI compatibility gains one new guarantee
A new ABI Compatibility section in the function pointer documentation explains what it means for function signatures to be ABI-compatible, including the compatibility of argument and return types. For the most part, this documentation adds no new guarantees; it describes the existing state of compatibility.
The new guarantee is that char and u32 are ABI-compatible. They have always had the same size and alignment, but Rust now also considers them equivalent in function-call ABI.
References can reveal otherwise unnameable types
Since Rust 1.38, any::type_name::<T>() has provided a string description of T for debugging, but it requires an explicit type parameter. That can be difficult for unnameable types such as closures and opaque return types. The new any::type_name_of_val(&T) instead obtains a descriptive name from a reference.
fn get_iter() -> impl Iterator<Item = i32> {
[1, 2, 3].into_iter()
}
fn main() {
let iter = get_iter();
let iter_name = std::any::type_name_of_val(&iter);
let sum: i32 = iter.sum();
println!("The sum of the `{iter_name}` is {sum}.");
}
This currently prints:
The sum of the `core::array::iter::IntoIter<i32, 3>` is 6.
Hashing types become available from std::hash
std::hash::{DefaultHasher, RandomState} are now stable at that path; they were previously available only through std::collections::hash_map. The release also stabilizes the shared-ownership, result and option inspection, type-name, and pointer APIs recorded below.