Rust 1.33.0
Released on February 28, 2019
What's Changed
- [You can now use the
cfg(target_vendor)attribute.][57465] E.g. - [Integer patterns such as in a match expression can now be exhaustive.][56362]
- [You can now have multiple patterns in
if letandwhile let - [You can now have irrefutable
if letandwhile letpatterns.][57535] Using - [You can now use
letbindings, assignments, expression statements, - [You can now call unsafe const functions.][57067] E.g.
- [You can now specify multiple attributes in a
cfg_attrattribute.][57332] - [You can now specify a specific alignment with the
#[repr(packed)] - [You can now import an item from a module as an
_.][56303] This allows you to - [You may now use
Rc,Arc, andPinas method receivers][56805].
- [You can now set a linker flavor for
rustcwith the-Clinker-flavor - [The minimum required LLVM version has been bumped to 6.0.][56642]
- [Added support for the PowerPC64 architecture on FreeBSD.][57615]
- [The
x86_64-fortanix-unknown-sgxtarget support has been upgraded to - [Added support for the
thumbv7neon-linux-androideabiand - [Added support for the
x86_64-unknown-uefitarget.][56769]
- [The methods
overflowing_{add, sub, mul, shl, shr}are nowconst - [The methods
rotate_left,rotate_right, andwrapping_{add, sub, mul, shl, shr} - [The methods
is_positiveandis_negativeare nowconstfunctions for - [The
getmethod for allNonZerotypes is nowconst.][57167] - [The methods
count_ones,count_zeros,leading_zeros,trailing_zeros, - [
Ipv4Addr::newis now aconstfunction][57234] - [
unix::FileExt::read_exact_at] - [
unix::FileExt::write_all_at] - [
Option::transpose] - [
Result::transpose] - [
convert::identity] - [
pin::Pin] - [
marker::Unpin] - [
marker::PhantomPinned] - [
Vec::resize_with] - [
VecDeque::resize_with] - [
Duration::as_millis] - [
Duration::as_micros] - [
Duration::as_nanos]
- [You can now publish crates that require a feature flag to compile with
- [Cargo should now rebuild a crate if a file was modified during the initial
- The methods
str::{trim_left, trim_right, trim_left_matches, trim_right_matches} - The
Error::causemethod has been deprecated in favor ofError::sourcewhich supports - [Libtest no longer creates a new thread for each test when
Full Changelog
Language
--------
- [You can now use the cfg(target_vendor) attribute.][57465] E.g.
#[cfg(target_vendor="apple")] fn main() { println!("Hello Apple!"); }
- [Integer patterns such as in a match expression can now be exhaustive.][56362]
E.g. You can have match statement on a u8 that covers 0..=255 and
you would no longer be required to have a _ => unreachable!() case.
- [You can now have multiple patterns in if let and while let
expressions.][57532] You can do this with the same syntax as a match
expression. 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 let and while let patterns.][57535] Using
this feature will by default produce a warning as this behaviour can be
unintuitive. E.g. if let _ = 5 {}
- [You can now use let bindings, assignments, expression statements,
and irrefutable pattern destructuring in const functions.][57175]
- [You can now call unsafe const functions.][57067] E.g.
const unsafe fn foo() -> i32 { 5 }
const fn bar() -> i32 {
unsafe { foo() }
}
- [You can now specify multiple attributes in a cfg_attr attribute.][57332]
E.g. #[cfg_attr(all(), must_use, optimize)]
- [You can now specify a specific alignment with the #[repr(packed)]
attribute.][57049] 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 _.][56303] This allows you to
import a trait's impls, and not have the name in the namespace. E.g.
use std::io::Read as _;
// Allowed as there is only one Read in the module.
pub trait Read {}
- [You may now use Rc, Arc, and Pin as method receivers][56805].
Compiler
--------
- [You can now set a linker flavor for rustc with the -Clinker-flavor
command line argument.][56351]
- [The minimum required LLVM version has been bumped to 6.0.][56642]
- [Added support for the PowerPC64 architecture on FreeBSD.][57615]
- [The x86_64-fortanix-unknown-sgx target support has been upgraded to
tier 2 support.][57130] Visit the [platform support][platform-support] page for
information on Rust's platform support.
- [Added support for the thumbv7neon-linux-androideabi and
thumbv7neon-unknown-linux-gnueabihf targets.][56947]
- [Added support for the x86_64-unknown-uefi target.][56769]
Libraries
---------
- [The methods overflowing_{add, sub, mul, shl, shr} are now const
functions for all numeric types.][57566]
- [The methods rotate_left, rotate_right, and wrapping_{add, sub, mul, shl, shr}
are now const functions for all numeric types.][57105]
- [The methods is_positive and is_negative are now const functions for
all signed numeric types.][57105]
- [The get method for all NonZero types is now const.][57167]
- [The methods count_ones, count_zeros, leading_zeros, trailing_zeros,
swap_bytes, from_be, from_le, to_be, to_le are now const for all
numeric types.][57234]
- [Ipv4Addr::new is now a const function][57234]
Stabilized APIs
---------------
- [unix::FileExt::read_exact_at]
- [unix::FileExt::write_all_at]
- [Option::transpose]
- [Result::transpose]
- [convert::identity]
- [pin::Pin]
- [marker::Unpin]
- [marker::PhantomPinned]
- [Vec::resize_with]
- [VecDeque::resize_with]
- [Duration::as_millis]
- [Duration::as_micros]
- [Duration::as_nanos]
Cargo
-----
- [You can now publish crates that require a feature flag to compile with
cargo publish --features or cargo publish --all-features.][cargo/6453]
- [Cargo should now rebuild a crate if a file was modified during the initial
build.][cargo/6484]
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 the str::{trim_start, trim_end, trim_start_matches, trim_end_matches}
methods instead.
- The Error::cause method has been deprecated in favor of Error::source which supports
downcasting.
- [Libtest no longer creates a new thread for each test when
--test-threads=1. It also runs the tests in deterministic order][56243]
[56243]: https://github.com/rust-lang/rust/pull/56243
[56303]: https://github.com/rust-lang/rust/pull/56303/
[56351]: https://github.com/rust-lang/rust/pull/56351/
[56362]: https://github.com/rust-lang/rust/pull/56362
[56642]: https://github.com/rust-lang/rust/pull/56642/
[56769]: https://github.com/rust-lang/rust/pull/56769/
[56805]: https://github.com/rust-lang/rust/pull/56805
[56947]: https://github.com/rust-lang/rust/pull/56947/
[57049]: https://github.com/rust-lang/rust/pull/57049/
[57067]: https://github.com/rust-lang/rust/pull/57067/
[57105]: https://github.com/rust-lang/rust/pull/57105
[57130]: https://github.com/rust-lang/rust/pull/57130/
[57167]: https://github.com/rust-lang/rust/pull/57167/
[57175]: https://github.com/rust-lang/rust/pull/57175/
[57234]: https://github.com/rust-lang/rust/pull/57234/
[57332]: https://github.com/rust-lang/rust/pull/57332/
[57465]: https://github.com/rust-lang/rust/pull/57465/
[57532]: https://github.com/rust-lang/rust/pull/57532/
[57535]: https://github.com/rust-lang/rust/pull/57535/
[57566]: https://github.com/rust-lang/rust/pull/57566/
[57615]: https://github.com/rust-lang/rust/pull/57615/
[cargo/6453]: https://github.com/rust-lang/cargo/pull/6453/
[cargo/6484]: https://github.com/rust-lang/cargo/pull/6484/
[unix::FileExt::read_exact_at]: https://doc.rust-lang.org/std/os/unix/fs/trait.FileExt.html#method.read_exact_at
[unix::FileExt::write_all_at]: https://doc.rust-lang.org/std/os/unix/fs/trait.FileExt.html#method.write_all_at
[Option::transpose]: https://doc.rust-lang.org/std/option/enum.Option.html#method.transpose
[Result::transpose]: https://doc.rust-lang.org/std/result/enum.Result.html#method.transpose
[convert::identity]: https://doc.rust-lang.org/std/convert/fn.identity.html
[pin::Pin]: https://doc.rust-lang.org/std/pin/struct.Pin.html
[marker::Unpin]: https://doc.rust-lang.org/stable/std/marker/trait.Unpin.html
[marker::PhantomPinned]: https://doc.rust-lang.org/nightly/std/marker/struct.PhantomPinned.html
[Vec::resize_with]: https://doc.rust-lang.org/std/vec/struct.Vec.html#method.resize_with
[VecDeque::resize_with]: https://doc.rust-lang.org/std/collections/struct.VecDeque.html#method.resize_with
[Duration::as_millis]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.as_millis
[Duration::as_micros]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.as_micros
[Duration::as_nanos]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.as_nanos
[platform-support]: https://forge.rust-lang.org/platform-support.html