Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
thatgeoguy.ca
...Matching enums By default Rust has built in support for deconstruction / pattern-matching enum types (even ones you define!). From our earlier example we can do: let x: PixelFormat; // Assume this is given a value from something match x { PixelFormat::Yuv{ y, u, v } => { println!("Pixel is y: {}, u: {}, v...
Rust Walkthroughs 2021-02-17 ~8 min read
llogiq.github.io
...Gankra asked nicely, so here’s a table with the results: # matches LInt name Comment 167 str_to_string very common elsewhere 102 needless_lifetimes probably old code 71 needless_return quite common elsewhere 32 approx_constant false positives 23 mut_mut may be false positives 19 float_cmp may...
From the Blogosphere 2015-09-07 ~5 min read
doc.rust-lang.org
...i32 = match p { Point(x, _) => x }; A unit-like struct is a struct without any fields, defined by leaving off the list of fields entirely. Such a struct implicitly defines a constant of its type with the same name. For example: struct Cookie; let c = [Cookie, Cookie {}, Cookie, Cookie {}]; is...
The Rust Reference Book 2024-01-01 ~1 min read
blog.logrocket.com
...Wiremock mocks HTTP responses using request matching and response templating techniques. Request matching checks if the incoming request meets specified conditions. You specify these conditions in the handler. Response templating helps to generate the content of the API response. Here’s an example of mocking with Wiremock: #[cfg(test)] mod...
Rust Walkthroughs 2023-05-24 ~16 min read
rustc-dev-guide.rust-lang.org
...match arms were matching in the wrong order". These comments are very useful to others later on when your test breaks, since they often can highlight what the problem is. They are also useful if for some reason the tests need to be refactored, since they let others know which...
Guide to Rustc Development Book 2024-01-01 ~6 min read
arxiv.org
...This work investigates aforementioned features, in particular pattern matching, providing a consistent view on how to apply MC/DC to Rust. Hence, this paper informs the implementation of Rust MC/DC tools, paving the road towards Rust in high-assurance applications. Comments: 19 pages, 1 figure, 9 listings Subjects: Software...
Research 2024-09-18 ~1 min read
udoprog.github.io
...I hope this makes it apparent why a byte-order naive application can’t process archives correctly unless the byte order used in the archive matches the native byte order. In order to interpret the values correctly we somehow need extra information and careful processing. The dictionary I built this...
Observations/Thoughts 2023-11-01 ~13 min read
blog.servo.org
...mrobinson corrected the behaviour of the scrollBy API to better match the specification. jdm removed incorrect buffer padding in ipc-channel on macOS. kvark fixed an assertion failure when rendering fonts on unix. aneeshusa implemented per-repository labelling actions in highfive. nox refactored the implementation of CSS position values to...
News & Blog Posts 2017-05-16 ~1 min read
llogiq.github.io
...The point is that the match follows some simple rules, and we can embed stuff from the match in the expression. We take a list of comma separated expressions (spaces don’t count), and take the first and the rest separately; the $(..),* in the match means zero or more comma...
News & Blog Posts 2016-05-02 ~13 min read
andreaskroepelin.de
...PlayerClass } impl PlayerClass { fn homestar(&self) -> String { use PlayerClass::*; match self { Sol(_) => String::from("sun"), ... } } fn greet(&self, other: &PlayerClass) { use PlayerClass::*; match (self, other) { (Cent(_), Pol(_)) => println!("Hello, fellow three-star-systemer!"), ... }; } } This indeed solves all our previous problems and is hence the go-to pattern for this situation...
Observations/Thoughts 2020-09-04 ~6 min read
rocket.rs
...The attribute describes the requests that match the route. The attribute is placed on top of a function that is the request handler for that route. As an example, consider the simple route below: 1 2 3 4#[get("/")] fn index() -> &'static str { "Hello, world!" } This index route matches any...
Crate of the Week 2023-11-22 ~6 min read
www.mattkennedy.io
...Enum methods require an implementation for each of the variants, which is done using pattern matching. enum Shape { Rectangle { width: f64, height: f64 }, Circle { radius: f64 }, RightAngleTriangle { base: f64, height: f64 }, } impl Shape { fn area(&self) -> f64 { match self { Shape::Rectangle { width, height } => width * height, Shape::Circle { radius } => std::f64...
Observations/Thoughts 2020-12-16 ~6 min read
blog.dureuill.net
...HashMap<Input, RequestStatus>, } impl Parser { pub fn new() -> Self { let (command_sender, command_receiver) = channel::<Command>(); let (response_sender, response_receiver) = channel::<(Input, Response)>(); std::thread::spawn(move || loop { match command_receiver.recv() { Ok(Command::Input(input)) => { let response = parse(input); let _ = response_sender.send((input, response)); } Ok(Command::Exit...
Observations/Thoughts 2024-02-14 ~6 min read
www.ralfj.de
...A Uniq item matches a Uniq tag with the same ID. A Shr item matches any Shr tag (with or without timestamp). When we are reading, a Shr item matches a Uniq tag. If we pop the entire stack without finding a match, then we have undefined behavior. To understand...
News & Blog Posts 2018-11-20 ~36 min read
blog.categulario.tk
...Enums y pattern matching. Aunque en el punto anterior mencioné los tipos unión este punto me parece tan importante que necesita su propio inciso. Es muy común cuando escribes código que estás ante la necesidad de representar información que viene en una de varias formas posibles. Hay formas muy tristes...
Observations/Thoughts 2020-08-11 ~6 min read
zellij.dev
...BTreeSet<{KeyModifier::Ctrl, KeyModifier::Shift}> } RustThe KeyWithModifier struct provides us with useful methods so that we can match against it in a readable way. Let’s look at our update function now:impl ZellijPlugin for State { // ... fn update(&mut self, event: Event) -> bool { let mut should_render = false; match event...
Rust Walkthroughs 2024-12-04 ~22 min read
sdleffler.github.io
...Smallfuck programs are strings of five instructions: < | Pointer decrement > | Pointer increment * | Flip current bit [ | If current bit is 0, jump past the matching ]; else, go to the next instruction ] | Jump back to the matching [ instruction This gives you the ability to select cells and make loops. Here’s a simple...
News & Blog Posts 2017-03-14 ~30 min read
doc.rust-lang.org
The ref pattern When doing pattern matching or destructuring via the let binding, the ref keyword can be used to take references to the fields of a struct/tuple. The example below shows a few instances where this can be useful: #[derive(Clone, Copy)] struct Point { x: i32, y: i32...
Rust by Example Book 2024-01-01 ~1 min read
dev.to
...Your First Service Next, let's open up the service.toml file for todo-service. [service] name = "my-service" [api] name = "my-service-api" [api.functions.my-function] name = "my-function" handler_name = "handler" Enter fullscreen mode Exit fullscreen mode Start by editing the names to match the ones we...
Learn Rust 2020-10-28 ~11 min read
jam1.re
...fn return_trait_object() -> Box<Any + Send + Sync> { todo!() } And since this still parses in spite of being deprecated, that means we can use it for our own nefarious macro purposes! (until it is inevitably removed) The Pattern Matching Unlike the function itself, matching on the anonymous sum type requires...
Observations/Thoughts 2020-11-18 ~9 min read
"apparently I wrote Building Git to explain a complex problem to rust devs who could then help me build it in rust"

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.