Rust 1.50 Improves Array Indexing |
Written by Kay Ewbank | |||
Thursday, 18 February 2021 | |||
The Rust team has announced a new release that offers improved array indexing, expanded safe access to union fields, and additions to the standard library. Rust was originally sponsored by Mozilla, and is intended for use in situations including embedding in other languages, writing programs with specific space and time requirements, and writing low-level code, like device drivers and operating systems. The development of Rust has just been safeguarded by the creation of the Rust Foundation, a cross-industry body aimed at supporting the language and its developers. The first improvement to the new release is support for const-generic array indexing. This is part of the team's work towards stable const generics, and specifically this release adds implementations of ops::Index and IndexMut for arrays. The indexing operator already worked on arrays through built-in compiler magic, but the library traits weren't actually implemented at the type level until now. Support has also been added for value repetition for arrays. This has actually worked as an accidental side effect of another change since Rust 1.38, but has now been formally included. The team says that in the future, to avoid such "temporary" named constants, you can look forward to inline Union fields are another area to have been improved, and it's now possible to safely make assignments to ManuallyDrop<T> union fields. This feature was added as part of an earlier improvement to supporting Drop for unions, but ManuallyDrop<T> doesn't need to Drop, so now Rust 1.50 allows safe assignments to these fields as well. The handling of Rust's File on Unix platforms has also been corrected. Rust treats some invalid values as a 'niche', and this space may be used for type layout optimizations. On Unix platforms, Rust's File is simply made of the system's integer file descriptor, and this happens to have a possible niche as well because it can never be -1. This niche is now added to the type's definition so it can be used in layout optimizations. Elsewhere, nine new stable functions have been added to the library including a variety of clamp functions to restrict a value to a certain interval. A number of other functions have been made const. More InformationRelated ArticlesRust Team Announces Rust Foundation Rust 2018 Released To Improve Developer Productivity Rust 1.26 Adds Existential Types Rust 1.20 Adds Associated Contents
To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.
Comments
or email your comment to: comments@i-programmer.info |
|||
Last Updated ( Monday, 21 June 2021 ) |