Rust 1.32.0
Language
2018 edition
- You can now use the
?operator in macro definitions. The?operator allows you to specify zero or one repetitions similar to the*and+operators. - Module paths with no leading keyword like
super,self, orcrate, will now always resolve to the item (enum,struct, etc.) available in the module if present, before resolving to a external crate or an item the prelude. E.g.enum Color { Red, Green, Blue } use Color::*;
All editions
- You can now match against
PhantomData<T>types. - You can now match against literals in macros with the
literalspecifier. This will match against a literal of any type. E.g.1,'A',"Hello World" - Self can now be used as a constructor and pattern for unit and tuple structs. E.g.
struct Point(i32, i32); impl Point { pub fn new(x: i32, y: i32) -> Self { Self(x, y) } pub fn is_origin(&self) -> bool { match self { Self(0, 0) => true, _ => false, } } }
- Self can also now be used in type definitions. E.g.
enum List<T> where Self: PartialOrd<Self> // can write `Self` instead of `List<T>` { Nil, Cons(T, Box<Self>) // likewise here }
- You can now mark traits with
#[must_use]. This provides a warning if aimpl Traitordyn Traitis returned and unused in the program.
Compiler
- The default allocator has changed from jemalloc to the default allocator on your system. The compiler itself on Linux & macOS will still use jemalloc, but programs compiled with it will use the system allocator.
- Added the
aarch64-pc-windows-msvctarget.
Libraries
PathBufnow implementsFromStr.Box<[T]>now implementsFromIterator<T>.- The
dbg!macro has been stabilized. This macro enables you to easily debug expressions in your rust program. E.g.let a = 2; let b = dbg!(a * 2) + 1; // ^-- prints: [src/main.rs:4] a * 2 = 4 assert_eq!(b, 5);
The following APIs are now const functions and can be used in a const context.
Cell::as_ptrUnsafeCell::getchar::is_asciiiter::emptyManuallyDrop::newManuallyDrop::into_innerRangeInclusive::startRangeInclusive::endNonNull::as_ptrslice::as_ptrstr::as_ptrDuration::as_secsDuration::subsec_millisDuration::subsec_microsDuration::subsec_nanosCStr::as_ptrIpv4Addr::is_unspecifiedIpv6Addr::newIpv6Addr::octets
Stabilized APIs
i8::to_be_bytesi8::to_le_bytesi8::to_ne_bytesi8::from_be_bytesi8::from_le_bytesi8::from_ne_bytesi16::to_be_bytesi16::to_le_bytesi16::to_ne_bytesi16::from_be_bytesi16::from_le_bytesi16::from_ne_bytesi32::to_be_bytesi32::to_le_bytesi32::to_ne_bytesi32::from_be_bytesi32::from_le_bytesi32::from_ne_bytesi64::to_be_bytesi64::to_le_bytesi64::to_ne_bytesi64::from_be_bytesi64::from_le_bytesi64::from_ne_bytesi128::to_be_bytesi128::to_le_bytesi128::to_ne_bytesi128::from_be_bytesi128::from_le_bytesi128::from_ne_bytesisize::to_be_bytesisize::to_le_bytesisize::to_ne_bytesisize::from_be_bytesisize::from_le_bytesisize::from_ne_bytesu8::to_be_bytesu8::to_le_bytesu8::to_ne_bytesu8::from_be_bytesu8::from_le_bytesu8::from_ne_bytesu16::to_be_bytesu16::to_le_bytesu16::to_ne_bytesu16::from_be_bytesu16::from_le_bytesu16::from_ne_bytesu32::to_be_bytesu32::to_le_bytesu32::to_ne_bytesu32::from_be_bytesu32::from_le_bytesu32::from_ne_bytesu64::to_be_bytesu64::to_le_bytesu64::to_ne_bytesu64::from_be_bytesu64::from_le_bytesu64::from_ne_bytesu128::to_be_bytesu128::to_le_bytesu128::to_ne_bytesu128::from_be_bytesu128::from_le_bytesu128::from_ne_bytesusize::to_be_bytesusize::to_le_bytesusize::to_ne_bytesusize::from_be_bytesusize::from_le_bytesusize::from_ne_bytes
Cargo
- You can now run
cargo cas an alias forcargo check. - Usernames are now allowed in alt registry URLs.
Misc
Compatibility Notes
- The argument types for AVX's
_mm256_stream_si256,_mm256_stream_pd,_mm256_stream_pshave been changed from*constto*mutas the previous implementation was unsound.