Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
doc.rust-lang.org
...The should_panic attribute The should_panic attribute causes a test to pass only if the [test function][attributes.testing.test] to which the attribute is applied panics. [!EXAMPLE] #[test] #[should_panic(expected = "values don't match")] fn mytest() { assert_eq!(1, 2, "values don't match"); } The should_panic...
The Rust Reference Book 2024-01-01 ~3 min read
minikin.me
...TrafficLightEvent) -> TrafficLightState { match (self, event) { // Normal cycle (TrafficLightState::Red, TrafficLightEvent::Timer) => TrafficLightState::Green, (TrafficLightState::Green, TrafficLightEvent::Timer) => TrafficLightState::Yellow, (TrafficLightState::Yellow, TrafficLightEvent::Timer) => TrafficLightState::Red, // Emergency override (_, TrafficLightEvent::Emergency) => TrafficLightState::Red, } } } // Usage fn main() { let mut state = TrafficLightState::Red; println!("Initial state: {:?}", state); // Normal cycle state = state.next(TrafficLightEvent::Timer...
Rust Walkthroughs 2025-03-19 ~22 min read
kerkour.com
...errs::Error) -> HttpResponse { let (status, code) = match &err { Error::AuthenticationRequired => (StatusCode::UNAUTHORIZED, "UNAUTHORIZED"), // 401 Error::PermissionDenied(_) => (StatusCode::FORBIDDEN, "FORBIDDEN"), // 403 Error::NotFound(_) => (StatusCode::NOT_FOUND, "NOT_FOUND"), // 404 _ => (StatusCode::INTERNAL_SERVER_ERROR, "INTERNAL_SERVER_ERROR"), // 500 }; let message = match &self { err @ Error::Internal(_) => { // log the internal error error!("{err}"); err...
Observations/Thoughts 2026-05-20 ~8 min read
doc.rust-lang.org
...Result<i32>) { match result { Ok(n) => println!("The first doubled is {}", n), Err(e) => println!("Error: {}", e), } } fn main() { let numbers = vec!["42", "93", "18"]; let empty = vec![]; let strings = vec!["tofu", "93", "18"]; print(double_first(numbers)); print(double_first(empty)); print(double_first(strings)); } See also: Dynamic dispatch...
Rust by Example Book 2024-01-01 ~1 min read
www.ncameron.org
...We will continue to accept any kind of bracket ((), [], {}) around the pattern, but the kind of bracket must match the use. Whilst new macros are being stabilised, these changes should cause deprecation warnings rather than errors to make adoption of the new macro system easier. Example, old macros: macro_rules...
News & Blog Posts 2015-12-14 ~6 min read
gfx-rs.github.io
...team ported WebRender over and got Firefox and Servo running on gfx-hal Our API has settled to be at the lowest level, practically matching Vulkan semantics now, and became completely unsafe. To compensate for this, we have started WebGPU implementation with the idea of it becoming the lowest safe...
News & Blog Posts 2019-01-01 ~1 min read
www.freecodecamp.org
...f32) -> f32 { match operator { '+' => first_number + second_number, '-' => first_number - second_number, '/' => first_number / second_number, '*' | 'X' | 'x' => first_number * second_number, _ => panic!("Invalid operator used."), } } The match expression works similarly to a switch statement in other languages. The match expression takes a value, and a list of arms. Each...
Rust Walkthroughs 2021-12-01 ~27 min read
matklad.github.io
...Option<Walrus>) { let walrus = match walrus { Some(it) => it, None => return, }; ... } As in the example above, this often comes up with preconditions: a function might check precondition inside and “do nothing” if it doesn’t hold, or it could push the task of precondition checking to its caller, and enforce...
Observations/Thoughts 2023-11-22 ~3 min read
qouteall.fun
...In that case the match expression outputs a value. That match has two branches. Each branch also output a value. Because the match target cache.get(&key) indirectly borrows cache mutably. And the second branch Some(v) => {v}'s output indirectly borrow match target. This indirect borrow of cache is...
Rust Walkthroughs 2025-10-29 ~64 min read
www.fluvio.io
...This meant that we needed a separate filter per pattern we wanted to match on. However we've added the capability to pass in user inputs at the time of execution. So we can have a single filter covering multiple patterns based on how we use it. This is an...
Project/Tooling Updates 2021-11-03 ~3 min read
rustc-dev-guide.rust-lang.org
...A node is considered to match a filter if all of those strings appear in its label. So, for example: RUST_DEP_GRAPH_FILTER='-> TypeckTables' would select the predecessors of all TypeckTables nodes. Usually though you want the TypeckTables node for some particular fn, so you might write: RUST_DEP...
Guide to Rustc Development Book 2024-01-01 ~3 min read
steveklabnik.com
...the profit from the book won’t go to me, it will go to OpenHatch, “a non-profit dedicated to matching prospective free software contributors with communities, tools, and education,” to use their words about it. I’ll let you know when we’re closer to actually shipping!
News & Blog Posts 2015-09-14 ~1 min read
github.com
...The drawbacks of this idea are covered in the motivation. ### Make `extern crate` match fuzzily Alternatively, we can have the compiler consider hyphens and underscores as equal while looking up a crate. In other words, the crate `flim-flam` would match both `extern crate flim_flam` and `extern crate "flim...
RFC 940 RFC 2015-03-05 ~3 min read
blogs.kde.org
...The mapping of completion match metadata to Kate's format (from fundamentals like the match type, to more complex features like smart grouping) can likely be improved still. Ditto for auto-completion behavior (i.e. defining the circumstances in which the completion popup will kick in automatically, as opposed to...
Project Updates 2015-05-18 ~3 min read
blog.aloni.org
...Pin<&mut Self>, _cx: &mut Context) -> Poll<Self::Output> { match self.fib.state { State::Halted => { self.fib.state = State::Running; Poll::Ready(()) } State::Running => { self.fib.state = State::Halted; Poll::Pending } } } } Executor Our executor keeps a vector of uncompleted futures, where the state of each future is located on the...
News & Blog Posts 2020-01-28 ~3 min read
aminediro.com
...u8, buf: &mut Vec<u8>) -> Result<usize> { loop { let (done, used) = { let available = match r.fill_buf() { // ... }; match memchr::memchr(delim, available) { Some(i) => { buf.extend_from_slice(&available[..=i]); (true, i + 1) } None => { buf.extend_from_slice(available); (false, available.len()) } } }; r.consume(used); read += used; if done || used...
Rust Walkthroughs 2024-01-24 ~22 min read
dev.to
...EnumValue<PhoneType>, // ... } // Match directly - the type carries the known/unknown distinction: match contact.phone_type { EnumValue::Known(PhoneType::MOBILE) => { /* ... */ } EnumValue::Known(PhoneType::HOME) => { /* ... */ } EnumValue::Known(PhoneType::WORK) => { /* ... */ } EnumValue::Unknown(v) => { /* v is the raw i32 from the wire */ } } // Or compare directly (PartialEq<E> is implemented): if contact.phone_type == PhoneType...
Project/Tooling Updates 2026-03-25 ~13 min read
llogiq.github.io
...bad_bit_mask, cmp_nan, eq_op, empty_loop, match_overlapping_arm, ineffective_bit_mask, min_max, modulo_one, nonsensical_open_options, out_of_bounds_indexing, range_step_by_zero, unit_cmp and others Readability – a good many lints suggest readability improvements, such as approx_constant, block_in_if_condition...
Notable New Crates & Project Updates 2016-02-01 ~3 min read
arxiv.org
...These guarantees come from a strong ownership-based type system, as well as primitive support for features like closures, pattern matching, etc., that make the code more concise and amenable to reasoning. These unique Rust features also pose a steep learning curve for programmers. This paper presents a tool called...
Research 2023-08-23 ~1 min read
fitzgeraldnick.com
...querying each field of a struct, matching on a variant and querying each of the matched variant’s children. It is also mechanically implemented inside #[derive(Term)]. The final querying puzzle piece is a combinator putting the one-layer querying traversal together with generic query functions into recursive querying traversal...
News & Blog Posts 2017-08-08 ~15 min read
"Failure is not an OPTION<T\>. It’s a Result<T, E\>."

Search tips

Type anything to search across articles, videos (including conference talks), podcasts, research, crates, and Rust API documentation. These operators give you finer control — click an example to try it.

Find pages containing all your words. Pages where the words appear together rank higher.
Quote part of your query to keep those words together as an exact phrase within a larger search.
Wrap the whole query in quotes for a verbatim search that matches text exactly, punctuation and all — perfect for Rust syntax. Needs at least 3 characters.
Limit results to a single site. Works on its own () too. One site: per search.

Use the tabs and filters above the results to narrow by content type, publication year, and sort order.