Email me

Rust versions / 1.40

Rust release · Dec 19, 2019

Rust 1.40: what's new, what was stabilized

Short answerRust 1.40 was released on Dec 19, 2019: 21 newly stable APIs (BTreeMap::get_key_value, HashMap::get_key_value, Option::as_deref_mut, Option::as_deref, ...); 3 compatibility notes that can affect existing code.

Dec 19, 2019release date
0language stabilizations
21APIs stabilized
-new edition

← Rust 1.39All versionsRust 1.41 →

21 APIs stabilized

BTreeMap::get_key_value, HashMap::get_key_value, Option::as_deref_mut, Option::as_deref, Option::flatten, UdpSocket::peer_addr, f32::to_be_bytes, f32::to_le_bytes, f32::to_ne_bytes, f64::to_be_bytes, f64::to_le_bytes, f64::to_ne_bytes, f32::from_be_bytes, f32::from_le_bytes, f32::from_ne_bytes, f64::from_be_bytes, f64::from_le_bytes, f64::from_ne_bytes, mem::take, slice::repeat, todo!

Can it break my build?

The release lists these compatibility notes. Most only affect rare code, but read them before you raise your toolchain in CI:

  • [As previously announced, any previous NLL warnings in the 2015 edition are
  • [The include! macro will now warn if it failed to include the
  • [Using #[inline] on function prototypes and consts now emits a warning under

Use it

rustup update stable        # get the newest release
rustup install 1.40          # or exactly this one
rustup override set 1.40     # pin a project to it

To require at least this version from users of your crate, set rust-version = "1.40" under [package] in Cargo.toml. Cargo then refuses to build it on older compilers with a clear message, and with resolver 3 (the default on the 2024 edition, Rust 1.85+) it also prefers dependency versions that support it.

Full release notes

Language

  • [You can now use tuple structs and tuple enum variant's constructors in const contexts.][65188] e.g.

```rust pub struct Point(i32, i32);

const ORIGIN: Point = { let constructor = Point;

constructor(0, 0) }; ```

  • [You can now mark structs, enums, and enum variants with the #[non_exhaustive] attribute to indicate that there may be variants or fields added in the future.][64639] For example this requires adding a wild-card branch (_ => {}) to any match statements on a non-exhaustive enum. [(RFC 2008)]
  • [You can now use function-like procedural macros in extern blocks and in type positions.][63931] e.g. type Generated = macro!();
  • [Function-like and attribute procedural macros can now emit macro_rules! items, so you can now have your macros generate macros.][64035]
  • [The meta pattern matcher in macro_rules! now correctly matches the modern attribute syntax.][63674] For example (#[$m:meta]) now matches #[attr], #[attr{tokens}], #[attr[tokens]], and #[attr(tokens)].

Compiler

  • [Added tier 3 support\* for the thumbv7neon-unknown-linux-musleabihf target.][66103]
  • [Added tier 3 support for the aarch64-unknown-none-softfloat target.][64589]
  • [Added tier 3 support for the mips64-unknown-linux-muslabi64, and mips64el-unknown-linux-muslabi64 targets.][65843]

\* Refer to Rust's [platform support page][platform-support-doc] for more information on Rust's tiered platform support.

Libraries

  • [The is_power_of_two method on unsigned numeric types is now a const function.][65092]

Stabilized APIs

  • [BTreeMap::get_key_value]
  • [HashMap::get_key_value]
  • [Option::as_deref_mut]
  • [Option::as_deref]
  • [Option::flatten]
  • [UdpSocket::peer_addr]
  • [f32::to_be_bytes]
  • [f32::to_le_bytes]
  • [f32::to_ne_bytes]
  • [f64::to_be_bytes]
  • [f64::to_le_bytes]
  • [f64::to_ne_bytes]
  • [f32::from_be_bytes]
  • [f32::from_le_bytes]
  • [f32::from_ne_bytes]
  • [f64::from_be_bytes]
  • [f64::from_le_bytes]
  • [f64::from_ne_bytes]
  • [mem::take]
  • [slice::repeat]
  • [todo!]

Cargo

  • [Cargo will now always display warnings, rather than only on fresh builds.][cargo/7450]
  • [Feature flags (except --all-features) passed to a virtual workspace will now produce an error.][cargo/7507] Previously these flags were ignored.
  • [You can now publish dev-dependencies without including a version.][cargo/7333]

Misc

  • [You can now specify the #[cfg(doctest)] attribute to include an item only when running documentation tests with rustdoc.][63803]

Compatibility Notes

Release notes from the Rust project's RELEASES.md (MIT or Apache-2.0); summaries above are ours.

← Rust 1.39All versionsRust 1.41 →

Up next

Next releaseRust 1.41Released Jan 30, 2020.Read it next →

Did this answer your question?

Get the receipts by email.

What my AI agents tried this week, with the real numbers: what worked, what flopped, what made money. One email when there is something worth reading.

No spam, never sold. Every email has a one-click unsubscribe.

Popular in the shop

All 124 tools →

Browse: Bundles and kitsHome, family and schoolMoney and businessAI toolsSports and fitnessMaking and hobbiesFood and drinkIndie dev and launchTrading and quant

Free: Landing page teardown iPhone app cost calculator LLM API cost calculator Paid online: $49 Launch Check App builds Articles FAQ