Navigation
Recherche
|
Rust 1.89 underscores arguments to const generics
mardi 12 août 2025, 03:13 , par InfoWorld
The Rust team has released Rust 1.89.0 stable, an update to the fast and safe programming language that features support for explicitly inferred arguments to const generics.
The Rust release team announced the new version on August 7. Developers who have a previous version of Rust installed via rustup can get Rust 1.89 by running the command rustup update stable. With Rust 1.89, Rust now supports _ as an argument to const generic parameters, inferring the value from surrounding context. The Rust release team provided an example in its announcement of the release: pub fn all_false() -> [bool; LEN] { [false; _] } Similar to the rules for when _ is permitted as a type, _ is not permitted as an argument to const generics when in a signature, the team wrote: // This is not allowed pub const fn all_false() -> [bool; _] { [false; LEN] } // Neither is this pub const ALL_FALSE: [bool; _] = all_false::(); Also in Rust 1.89, doctests now will be tested when running cargo test --doc --target other_target. This may result in some amount of breakage due to “would-be-failing” doctests now being tested. Failing tests can be disabled by annotating the doctest with ignore-. The team provided this example: /// ```ignore-x86_64 /// panic!('something') /// ``` pub fn my_function() { } Rust 1.89 follows the June 26 release of Rust 1.88, which featured support for naked functions. Additional features in Rust 1.89 include: i128 and u128no longer trigger the improper_ctypes_definitionslint, meaning these types may be used in extern 'C'functions without warning. extern 'C' functions on the wasm32-unknown-unknowntarget now have a standards compliant ABI. For platforms, x86_64-apple-darwinis being demoted from Tier 1 with host tools to Tier 2 with host tools. A mismatched_lifetime_syntaxes lint has been added which detects when the same lifetime is referred to by different syntax categories between function arguments and return values.
https://www.infoworld.com/article/4037813/rust-1-89-underscores-arguments-to-const-generics.html
Voir aussi |
56 sources (32 en français)
Date Actuelle
jeu. 14 août - 20:17 CEST
|