Rust ranged patterns can now use exclusive endpoints, written a..b or ..b similar to the Range and RangeTo expression types.Rust ranged patterns can now use exclusive endpoints, written a..b or ..b similar to the Range and RangeTo expression types.

Rust 1.80.0: Exclusive Ranges in Patterns, Stabilized APIs, and More

2025/09/28 23:45
5 min di lettura
Per feedback o dubbi su questo contenuto, contattateci all'indirizzo crypto.news@mexc.com.

The Rust team is happy to announce a new version of Rust, 1.80.0. Rust is a programming language empowering everyone to build reliable and efficient software.

\ If you have a previous version of Rust installed via rustup, you can get 1.80.0 with:

$ rustup update stable 

\ If you don't have it already, you can get rustup from the appropriate page on our website, and check out the detailed release notes for 1.80.0.

\ If you'd like to help us out by testing future releases, you might consider updating locally to use the beta channel (rustup default beta) or the nightly channel (rustup default nightly). Please report any bugs you might come across!

What's in 1.80.0 stable

LazyCell and LazyLock

These "lazy" types delay the initialization of their data until first access. They are similar to the OnceCell and OnceLock types stabilized in 1.70, but with the initialization function included in the cell. This completes the stabilization of functionality adopted into the standard library from the popular lazy_static and once_cell crates.

\ LazyLock is the thread-safe option, making it suitable for places like static values. For example, both the spawn thread and the main scope will see the exact same duration below, since LAZY_TIME will be initialized once, by whichever ends up accessing the static first. Neither use has to know how to initialize it, unlike they would with OnceLock::get_or_init().

use std::sync::LazyLock; use std::time::Instant;  static LAZY_TIME: LazyLock<Instant> = LazyLock::new(Instant::now);  fn main() {     let start = Instant::now();     std::thread::scope(|s| {         s.spawn(|| {             println!("Thread lazy time is {:?}", LAZY_TIME.duration_since(start));         });         println!("Main lazy time is {:?}", LAZY_TIME.duration_since(start));     }); } 

LazyCell does the same thing without thread synchronization, so it doesn't implement Sync, which is needed for static, but it can still be used in thread_local! statics (with distinct initialization per thread). Either type can also be used in other data structures as well, depending on thread-safety needs, so lazy initialization is available everywhere!

Checked cfg names and values

In 1.79, rustc stabilized a --check-cfg flag, and now Cargo 1.80 is enabling those checks for all cfg names and values that it knows (in addition to the well known names and values from rustc). This includes feature names from Cargo.toml as well as new cargo::rustc-check-cfg output from build scripts.

\ Unexpected cfgs are reported by the warn-by-default unexpected_cfgs lint, which is meant to catch typos or other misconfiguration. For example, in a project with an optional rayon dependency, this code is configured for the wrong feature value:

fn main() {     println!("Hello, world!");      #[cfg(feature = "crayon")]     rayon::join(         || println!("Hello, Thing One!"),         || println!("Hello, Thing Two!"),     ); }   warning: unexpected `cfg` condition value: `crayon`  --> src/main.rs:4:11   | 4 |     #[cfg(feature = "crayon")]   |           ^^^^^^^^^^--------   |                     |   |                     help: there is a expected value with a similar name: `"rayon"`   |   = note: expected values for `feature` are: `rayon`   = help: consider adding `crayon` as a feature in `Cargo.toml`   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration   = note: `#[warn(unexpected_cfgs)]` on by default 

The same warning is reported regardless of whether the actual rayon feature is enabled or not.

\ The [lints] table in the Cargo.toml manifest can also be used to extend the list of known names and values for custom cfg. rustc automatically provides the syntax to use in the warning.

[lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ['cfg(foo, values("bar"))'] } 

\ You can read more about this feature in a previous blog post announcing the availability of the feature on nightly.

Exclusive ranges in patterns

Rust ranged patterns can now use exclusive endpoints, written a..b or ..b similar to the Range and RangeTo expression types. For example, the following patterns can now use the same constants for the end of one pattern and the start of the next:

pub fn size_prefix(n: u32) -> &'static str {     const K: u32 = 10u32.pow(3);     const M: u32 = 10u32.pow(6);     const G: u32 = 10u32.pow(9);     match n {         ..K => "",         K..M => "k",         M..G => "M",         G.. => "G",     } } 

\ Previously, only inclusive (a..=b or ..=b) or open (a..) ranges were allowed in patterns, so code like this would require separate constants for inclusive endpoints like K - 1.

\ Exclusive ranges have been implemented as an unstable feature for a long time, but the blocking concern was that they might add confusion and increase the chance of off-by-one errors in patterns. To that end, exhaustiveness checking has been enhanced to better detect gaps in pattern matching, and new lints non_contiguous_range_endpoints and overlapping_range_endpoints will help detect cases where you might want to switch exclusive patterns to inclusive, or vice versa.

Stabilized APIs

  • impl Default for Rc<CStr>
  • impl Default for Rc<str>
  • impl Default for Rc<[T]>
  • impl Default for Arc<str>
  • impl Default for Arc<CStr>
  • impl Default for Arc<[T]>
  • impl IntoIterator for Box<[T]>
  • impl FromIterator<String> for Box<str>
  • impl FromIterator<char> for Box<str>
  • LazyCell
  • LazyLock
  • Duration::div_duration_f32
  • Duration::div_duration_f64
  • Option::take_if
  • Seek::seek_relative
  • BinaryHeap::as_slice
  • NonNull::offset
  • NonNull::byte_offset
  • NonNull::add
  • NonNull::byte_add
  • NonNull::sub
  • NonNull::byte_sub
  • NonNull::offset_from
  • NonNull::byte_offset_from
  • NonNull::read
  • NonNull::read_volatile
  • NonNull::read_unaligned
  • NonNull::write
  • NonNull::write_volatile
  • NonNull::write_unaligned
  • NonNull::write_bytes
  • NonNull::copy_to
  • NonNull::copy_to_nonoverlapping
  • NonNull::copy_from
  • NonNull::copy_from_nonoverlapping
  • NonNull::replace
  • NonNull::swap
  • NonNull::drop_in_place
  • NonNull::align_offset
  • <[T]>::split_at_checked
  • <[T]>::split_at_mut_checked
  • str::split_at_checked
  • str::split_at_mut_checked
  • str::trim_ascii
  • str::trim_ascii_start
  • str::trim_ascii_end
  • <[u8]>::trim_ascii
  • <[u8]>::trim_ascii_start
  • <[u8]>::trim_ascii_end
  • Ipv4Addr::BITS
  • Ipv4Addr::to_bits
  • Ipv4Addr::from_bits
  • Ipv6Addr::BITS
  • Ipv6Addr::to_bits
  • Ipv6Addr::from_bits
  • Vec::<[T; N]>::into_flattened
  • <[[T; N]]>::as_flattened
  • <[[T; N]]>::as_flattened_mut

These APIs are now stable in const contexts:

  • <[T]>::last_chunk
  • BinaryHeap::new

Other changes

Check out everything that changed in Rust, Cargo, and Clippy.

Contributors to 1.80.0

Many people came together to create Rust 1.80.0. We couldn't have done it without all of you. Thanks!


The Rust Release Team

\ Also published here

\ Photo by Lay Naik on Unsplash

Opportunità di mercato
Logo Moonveil
Valore Moonveil (MORE)
$0,0004608
$0,0004608$0,0004608
-2,78%
USD
Grafico dei prezzi in tempo reale di Moonveil (MORE)
Disclaimer: gli articoli ripubblicati su questo sito provengono da piattaforme pubbliche e sono forniti esclusivamente a scopo informativo. Non riflettono necessariamente le opinioni di MEXC. Tutti i diritti rimangono agli autori originali. Se ritieni che un contenuto violi i diritti di terze parti, contatta crypto.news@mexc.com per la rimozione. MEXC non fornisce alcuna garanzia in merito all'accuratezza, completezza o tempestività del contenuto e non è responsabile per eventuali azioni intraprese sulla base delle informazioni fornite. Il contenuto non costituisce consulenza finanziaria, legale o professionale di altro tipo, né deve essere considerato una raccomandazione o un'approvazione da parte di MEXC.

Potrebbe anche piacerti

Original Penguin Sues Pudgy Penguins Over Trademark Dispute

Original Penguin Sues Pudgy Penguins Over Trademark Dispute

TLDR Original Penguin sues Pudgy Penguins for alleged trademark misuse. PEI targets crypto brand over penguin-themed apparel and headwear. Lawsuit demands stop
Condividi
Coincentral2026/03/06 21:09
NGP Token Crashes 88% After $2M Oracle Hack

NGP Token Crashes 88% After $2M Oracle Hack

The post NGP Token Crashes 88% After $2M Oracle Hack appeared on BitcoinEthereumNews.com. Key Notes The attacker stole ~$2 million worth of ETH from the New Gold Protocol on Sept.18. The exploit involved a flash loan that successfully manipulated the price oracle enabling the attacker to bypass security checks in the smart contract. The NGP token is down 88% as the attacker obfuscates their funds through Tornado Cash. New Gold Protocol, a DeFi staking project, lost around 443.8 Ethereum ETH $4 599 24h volatility: 2.2% Market cap: $555.19 B Vol. 24h: $42.83 B , valued at $2 million, in an exploit on Sept 18. The attack caused the project’s native NGP token to crash by 88%, wiping out most of its market value in less than an hour. The incident was flagged by multiple blockchain security firms, including PeckShield and Blockaid. Both firms confirmed the amount stolen and tracked the movement of the funds. Blockaid’s analysis identified the specific vulnerability that the attacker used. 🚨 Community Alert: Blockaid’s exploit detection system identified multiple malicious transactions targeting the NGP token on BSC. Roughly $2M has been drained. ↓ We’re monitoring in real time and will share updates below pic.twitter.com/efxXma0REQ — Blockaid (@blockaid_) September 17, 2025 Flash Loan Attack Manipulated Price Oracle According to the Blockaid report, the hack was a price oracle manipulation attack. The protocol’s smart contract had a critical flaw; it determined the NGP token’s price by looking at the asset reserves in a single Uniswap liquidity pool. This method is insecure because a single pool’s price can be easily manipulated. The attacker used a flash loan to borrow a large amount of assets. A flash loan consists of a series of transactions that borrow and return a loan within the same transaction. They used these assets to temporarily skew the reserves in the liquidity pool, tricking the protocol into thinking the…
Condividi
BitcoinEthereumNews2025/09/18 19:04
American Manufacturing Has A Private Equity Problem

American Manufacturing Has A Private Equity Problem

The post American Manufacturing Has A Private Equity Problem appeared on BitcoinEthereumNews.com. Private equity would seem to be a natural fit for SME manufacturers’ increasing needs for growth and buyout capital. But there’s a problem. getty Baby Boom owners of small- and medium-sized enterprise manufacturing companies, which comprise about 98% of American industry, are reaching retirement age in droves, with Generation X not far behind. Those without relatives or partners to take over the businesses need to find buyers so they can exit. Private equity investors would seem to be the natural answer. Unfortunately, there exists a critical distrust of PE among industrial owners. Matt Guse is president of MRS Machining in Augusta, Wisconsin, a family-owned machine shop established by his dad in 1986. Author of the new book MRS Machining: A Manufacturing Story, Guse published an article on LinkedIn last week giving one reason for that great level of distrust among owners looking to sell. There’s a gap right now in manufacturing that mostly gets swept under the rug—a real disconnect between buyers and sellers that goes way deeper than price. Almost every week, I hear from private equity firms or buyers circling manufacturing businesses, coming in with their own playbooks. But let’s be honest: most buyers still approach business owners like they’re handing them a favor, tossing out the same tired 2x–4x multiples, assuming owners are desperate to cash out. That attitude misses the point entirely. Manufacturing business owners aren’t just selling off machines and real estate. They’re putting decades of hard work, community, and identity on the line. These are their legacies, not just another transaction to check off a spreadsheet. Treating these deals as cold, purely financial moves ignores everything that actually makes these businesses valuable in the first place. There’s a much deeper level of distrust that dates back about as long as MRS Machining has been…
Condividi
BitcoinEthereumNews2025/09/18 05:05