Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
steveklabnik.com
...u32 = match guess.trim().parse() { Ok(num) => num, Err(_) => continue, }; println!("You guessed: {}", guess); match guess.cmp(&secret_number) { Ordering::Less => println!("Too small!"), Ordering::Greater => println!("Too big!"), Ordering::Equal => { println!("You win!"); break; } } } } We aren’t quite properly re-using the buffer here, but we could modify this...
Learn Simple Rust 2020-10-21 ~4 min read
siciarz.net
...u8) -> OpCode { match opcode { 0 => OpCode::Continue, 1 => OpCode::Text, 2 => OpCode::Binary, 8 => OpCode::Close, 9 => OpCode::Ping, 10 => OpCode::Pong, _ => OpCode::Reserved, } } } #[derive(Debug)] struct WebSocketFrame { fin: bool, opcode: OpCode, mask: bool, length: u64, masking_key: u16, payload: Vec<u8>, } We're using a custom enum to make...
24 Days of Rust 2016-12-13 ~5 min read
lazy.codes
...match x { 1 + 3 => {} } results in a syntax error while match x { const { 1 + 3 } => {} }does not. if_let_guard Extends the if guards that you can use with match statements to be able to use if let. let_chains Currently, if let and while let expressions can not be...
Rust Walkthroughs 2021-07-28 ~18 min read
dev.to
...if let Some(e) = err.find::<Error>() Enter fullscreen mode Exit fullscreen mode In such case, we'll match each and every Error branch and return an appropriate response. Matching against ValidationError will extract validation errors and serialize them as part of request. In a real world scenario, you'd...
Rust Walkthroughs 2021-01-27 ~4 min read
developer.ibm.com
...In this context, I match _f against the possible error values (Ok and Err). For Ok, I return the file for assignment; for Err, I use panic!. use std::fs::File; fn main() { let _f = File::open("file.txt"); let _f = match _f { Ok(file) => file, Err(why) => panic!("Error...
Observations/Thoughts 2021-01-06 ~11 min read
github.com
...And requiring matching on every use of the type is less ergonomic. For example, the clamp RFC would naturally use a `RangeInclusive` parameter, but because it still needs to `assert!(start <= end)` in the `NonEmpty` arm, the noise of the `Empty` vs `NonEmpty` match provides it no value. - `a...b...
RFC 1192 RFC 2015-07-07 ~5 min read
doc.rust-lang.org
...invalid lifetime parameter name: `'static` fn invalid_lifetime_parameter<'static>(s: &'static str) -> &'static str { s } • safe is used for functions and statics, which has meaning in external blocks. • raw is used for raw borrow operators, and is only a keyword when matching a raw borrow operator form (such as...
The Rust Reference Book 2024-01-01 ~2 min read
smallcultfollowing.com
...It’s at least kind of scary.On a related note, right now, because match code is built into the compiler, we allow it to inspect freely without worrying about whether data is mutably borrowed or not. We know, after all, that during a match the only possibility for side...
Announcements etc 2013-11-19 ~13 min read
rust-lang.github.io
...As such, the lang team will need to approve the high-level answer. • Do match guards have semantic meaning? Match guards are inserted by the compiler around match statements to ensure that if guards cannot change the value being matched on. Whether match guards should exist at all primarily affects...
RFC 3346 RFC 2022-11-07 ~8 min read
thunderseethe.dev
...comb.goal.clone(), }) } else { None } }); match poss_uni { // Unify if we have a match Some(match_comb) => { self.unify_row_row(new_comb.left, match_comb.left)?; self.unify_row_row(new_comb.right, match_comb.right)?; self.unify_row_row(new_comb.goal, match_comb.goal)?; } // Otherwise add our...
Observations/Thoughts 2023-10-25 ~29 min read
rust-analyzer.github.io
Fixes #13749 don’t show duplicated adjustment hints for blocks, ifs and matches. #13742 only shift BoundVars that come from outside lowering context (fixes a crash with GATs). #13750 normalize projection after discarding free BoundVars in RPIT (fixes a crash during normalization).
Project/Tooling Updates 2022-12-14 ~1 min read
brson.github.io
...util canvas->azure canvas->geom canvas->cssparser canvas->gleam canvas->num offscreen_gl_context offscreen_gl_context canvas->offscreen_gl_context cssparser->encoding matches matches cssparser->matches gleam->libc gl_common gl_common gleam->gl_common gl_generator gl_generator gleam->gl_generator khronos_api khronos_api gleam->khronos_api...
Notable Links 2015-05-18 ~3 min read
blog.urth.org
...That’s because I’m using Rust’s enum-based pattern matching. The Node enum has over 100 variants. That’s a lot of matching!I also need to generate enum wrappers around many structs. Any time a struct references another struct, I need the wrapper indirection. So for example...
Observations/Thoughts 2021-03-17 ~9 min read
blog.cloudflare.com
...right hand side is parsed and used as a byte sequence (will match a URL "/1234567")Are there other examples of such ambiguities? Yup - for example, we can try using a single number with two decimal digits:tcp.port == 80: matches any traffic on the port 80 (HTTP)http.file...
News & Blog Posts 2019-03-05 ~17 min read
rust-lang.github.io
...Usually, you'll want to copy this value from a corresponding -fpatchable-function-entry= being passed to the C compiler in your project - total_nops will match the first parameter used by your C compiler, and the optional offset parameter passed to the C compiler will match prefix_nops. To...
RFC 3543 RFC 2023-12-12 ~11 min read
rust-lang.github.io
...Motivation Right now accessing fields of tuples and tuple structs is incredibly painful—one must rely on pattern-matching alone to extract values. This became such a problem that twelve traits were created in the standard library (core::tuple::Tuple*) to make tuple value accesses easier, adding .valN(), .refN(), and...
RFC 184 RFC 2014-07-24 ~1 min read
ettolrach.com
...Expr::App(l, m) => match infer(*l, context)? { Type::Arrow(a, b) => match check(*m.clone(), *a, context) { Ok(_) => Ok(*b), Err(TypeError { kind: ErrorKind::CheckedWrongType { expected: a, actual, }, line, column, }) => Err(TypeError { kind: ErrorKind::ArgWrongType { expected: a, actual, }, line, column, }), Err(e) => Err(e), }, actual => Err(TypeError { kind: ErrorKind...
Observations/Thoughts 2025-12-31 ~15 min read
dev.to
...Option<&mut FdSet>) -> *mut libc::fd_set { match opt { None => ptr::null_mut(), Some(&mut FdSet(ref mut raw_fd_set)) => raw_fd_set, } } fn to_ptr<T>(opt: Option<&T>) -> *const T { match opt { None => ptr::null::<T>(), Some(p) => p, } } pub fn select( nfds: libc::c_int, readfds...
Rust Walkthroughs 2020-11-25 ~12 min read
blog.sheerluck.dev
...LIKE and Pattern Matching# LIKE does pattern matching on text. Two wildcards: % matches any sequence of characters (including zero) _ matches exactly one character SELECT title FROM books WHERE title LIKE '%Rust%'; Output: title --------------------------- The Rust Programming Langua %Rust% means “anything, then Rust, then anything.” It finds any title containing the...
Rust Walkthroughs 2026-07-01 ~51 min read
ryangjchandler.co.uk
...fn compile_function(function: &Statement, source: &mut String) -> Result<(), CompileError> { let (name, params, body) = match function { Statement::Function { name, params, body, .. } => (name, params, body), _ => unreachable!(), }; source.push_str("fn "); source.push_str(&name.name); source.push('('); for param in params { source.push_str(match &param.name { Expression::Variable(n) => &n...
Rust Walkthroughs 2022-08-24 ~13 min read
"I find it amazing that by using Rust and Miri I am using tools that are on the edge of fundamental research in Programming Languages. Actual practical..."

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.
Put ! first to open the top result immediately. Quote the whole query for a literal leading bang, as in '!Send'. Bangs elsewhere, such as println!, stay literal. Browser and launcher shortcuts can invoke this directly. See search integrations.
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.