rustbites rustbites bite-sized rust tips
Archives About
#024 Dec 24, 2022
option iterator

24. ..=X

As of 1.66, it is possible to use ..=X in patterns

1
2
3
4
5
6
let result = 20u32;

match result {
    0..=20 => println!("Included"),
    21.. => println!("Sorry"),
}

This post is licensed under CC BY 4.0 by the author.

Share:
← Previous 25. Option's iterator Next → 27. Option's sum/product

Trending Tags

Rust Iterator Option Iter Iterators Result Collections Enum Macro Match Std Vec Array-Windows Arrays Async Attributes Break Closure Closures Combinators Compiler Concurrency Cow Debugging Default Drain Entry Enumerate Error-Handling Filter Flatten Fn Fnmut Fnonce Fold From_fn Functional Hashmap If-Let Initialization Lazy Lazylock Loop Map Matching Mem Ownership Pattern-Matching Performance Pettern Position Raw String Scan Scoped-Threads Slices Smart-Pointers Static Stdlib String Strings Threads Tokio Trait-Objects Traits Upcasting

Recently updated

#043 43. Vec::extract_if — Remove Elements and Keep Them #042 42. array::from_fn — Build Arrays from a Function #041 41. Async Closures — Pass Async Code Like Any Other Closure #040 40. Scoped Threads — Borrow Across Threads Without Arc #039 39. Trait Upcasting — Cast dyn Trait to dyn Supertrait

About

A collection of bite-sized Rust tips and tricks. Small, focused lessons to help you write better Rust.

info@rustbites.com
rustbites rustbites · 2022—2026
X RSS

This site uses cookies for analytics and ads. Learn more