Version 1.33.0 (2019-02-28)
Language
- You can now use the
cfg(target_vendor)attribute. E.g.#[cfg(target_vendor="apple")] fn main() { println!("Hello Apple!"); } - Integer patterns such as in a match expression can now be exhaustive.
E.g. You can have match statement on a
u8that covers0..=255and you would no longer be required to have a_ => unreachable!()case. - You can now have multiple patterns in
if letandwhile letexpressions. You can do this with the same syntax as amatchexpression. E.g.enum Creature { Crab(String), Lobster(String), Person(String), } fn main() { let state = Creature::Crab("Ferris"); if let Creature::Crab(name) | Creature::Person(name) = state { println!("This creature's name is: {}", name); } } - You can now have irrefutable
if letandwhile letpatterns. Using this feature will by default produce a warning as this behaviour can be unintuitive. E.g.if let _ = 5 {} - You can now use
letbindings, assignments, expression statements, and irrefutable pattern destructuring in const functions. - You can now call unsafe const functions. E.g.
#![allow(unused)] fn main() { const unsafe fn foo() -> i32 { 5 } const fn bar() -> i32 { unsafe { foo() } } } - You can now specify multiple attributes in a
cfg_attrattribute. E.g.#[cfg_attr(all(), must_use, optimize)] - You can now specify a specific alignment with the
#[repr(packed)]attribute. E.g.#[repr(packed(2))] struct Foo(i16, i32);is a struct with an alignment of 2 bytes and a size of 6 bytes. - You can now import an item from a module as an
_. This allows you to import a trait's impls, and not have the name in the namespace. E.g.#![allow(unused)] fn main() { use std::io::Read as _; // Allowed as there is only one `Read` in the module. pub trait Read {} } - You may now use
Rc,Arc, andPinas method receivers.
Compiler
- You can now set a linker flavor for
rustcwith the-Clinker-flavorcommand line argument. - The minimum required LLVM version has been bumped to 6.0.
- Added support for the PowerPC64 architecture on FreeBSD.
- The
x86_64-fortanix-unknown-sgxtarget support has been upgraded to tier 2 support. Visit the platform support page for information on Rust's platform support. - Added support for the
thumbv7neon-linux-androideabiandthumbv7neon-unknown-linux-gnueabihftargets. - Added support for the
x86_64-unknown-uefitarget.
Libraries
- The methods
overflowing_{add, sub, mul, shl, shr}are nowconstfunctions for all numeric types. - The methods
rotate_left,rotate_right, andwrapping_{add, sub, mul, shl, shr}are nowconstfunctions for all numeric types. - The methods
is_positiveandis_negativeare nowconstfunctions for all signed numeric types. - The
getmethod for allNonZerotypes is nowconst. - The methods
count_ones,count_zeros,leading_zeros,trailing_zeros,swap_bytes,from_be,from_le,to_be,to_leare nowconstfor all numeric types. Ipv4Addr::newis now aconstfunction
Stabilized APIs
unix::FileExt::read_exact_atunix::FileExt::write_all_atOption::transposeResult::transposeconvert::identitypin::Pinmarker::Unpinmarker::PhantomPinnedVec::resize_withVecDeque::resize_withDuration::as_millisDuration::as_microsDuration::as_nanos
Cargo
- You can now publish crates that require a feature flag to compile with
cargo publish --featuresorcargo publish --all-features. - Cargo should now rebuild a crate if a file was modified during the initial build.
Compatibility Notes
- The methods
str::{trim_left, trim_right, trim_left_matches, trim_right_matches}are now deprecated in the standard library, and their usage will now produce a warning. Please use thestr::{trim_start, trim_end, trim_start_matches, trim_end_matches}methods instead. - The
Error::causemethod has been deprecated in favor ofError::sourcewhich supports downcasting. - Libtest no longer creates a new thread for each test when
--test-threads=1. It also runs the tests in deterministic order