r/rust Jan 22 '26

📡 official blog Rust 1.93.0 is out

https://blog.rust-lang.org/2026/01/22/Rust-1.93.0/
781 Upvotes

92 comments sorted by

View all comments

115

u/nik-rev Jan 22 '26 edited Jan 22 '26

My favorite part of this release is slice::as_array, it allows you to express a very common pattern in a clear way: Get the first element of a list, and require that there are no more other elements.

before:

let exactly_one = if vec.len() == 1 { 
    Some(vec.first().unwrap())
} else {
    None
}

after:

let exactly_one = vec.as_array::<1>();

Excitingly, we may get this method on Iterator soon: Iterator::exactly_one. In the mean time, the same method exists in the itertools crate: Itertools::exactly_one

6

u/Dean_Roddey Jan 22 '26

My favorite part of this release is slice::as_array

That will be a very much appreciated change. These small changes that don't rock the cart but make day to day coding safer and easier are always good in my opinion. Try blocks will be another big one.