Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
doc.rust-lang.org
...match page_title(url).poll() { Ready(page_title) => match page_title { Some(title) => println!("The title for {url} was {title}"), None => println!("{url} had no title"), } Pending => { // But what goes here? } } What should we do when the future is still Pending? We need some way to try again, and again...
The Rust Programming Language Book 2024-02-01 ~17 min read
developerlife.com
...let (tcp_stream, socket_addr) = tcp_listener.accept().await?; let tx = tx.clone(); tokio::spawn(async move { let result = handle_client_task(tcp_stream, tx, socket_addr).await; match result { Ok(_) => { log::info!("handle_client_task() terminated gracefully") } Err(error) => log::error!("handle_client_task() encountered error: {}", error), } }); } } To run...
Rust Walkthroughs 2024-02-14 ~8 min read
asquera.de
...racer complete std::io::B You should see several matches from this. At this point racer is set up and ready to be used in your editor or with rls. rls Why do we want this? It enables a much richer development experience and extends on the capabilities of racer...
News & Blog Posts 2017-03-07 ~12 min read
doc.rust-lang.org
...base}; // OK, only base.x is accessed drop(y_ref); Struct expressions can't be used directly in a loop or if expression's head, or in the scrutinee of an if let or match expression. However, struct expressions can be used in these situations if they are within another...
The Rust Reference Book 2024-01-01 ~3 min read
llogiq.github.io
...With some investment into optimizations, matching or exceeding C’s speed should be possible in most cases. However, Rust makes some tradeoffs for different reasons than sheer speed, so here’s a handy list of some things that may bite you and how you can speed them up. Before we...
News & Blog Posts 2017-06-06 ~8 min read
kerkour.com
...In an analysis, Adam Harvey found that among the 999 most popular crates on crates.io, around 17% contained code that do not match their code repository. 17%! Let me rephrase this, 17% of the most popular Rust packages contain code that virtually nobody knows what it does (I can...
Observations/Thoughts 2026-08-26 ~13 min read
dpbriggs.ca
...There's no way to express x7 functions in terms of MyData let res = match expr { Expr::Num(i) => MyData::Int(i.to_u64()?), // to_u64 is a ExprHelper method Expr::String(s) => MyData::String(s.clone()), unknown_type => { let err_msg = format!("{} cannot be converted to MyData", unknown_type...
Rust Walkthroughs 2021-01-06 ~12 min read
developerlife.com
...let command_to_run_with_each_selection = match maybe_command_to_run_with_each_selection { Some(it) => it, None => { print_help_for_subcommand_and_option( "select-from-list", "command-to-run-with-each-selection", ) .ok(); let mut line_editor = Reedline::create(); let prompt = DefaultPrompt { left_prompt: DefaultPromptSegment::Basic( "Enter command...
Rust Walkthroughs 2023-09-20 ~7 min read
hackernoon.com
...Again, we destructure that Option by using the if let pattern matching syntax which will execute the block if the function returns “some account”. If it doesn’t, we drop an error message. After the pre-checks follows the implementation of the transaction’s specific logic pieces:The statement match...
Learn More Rust 2020-08-18 ~41 min read
vorner.github.io
...use signal_hook::SIGHUP; use signal_hook::iterator::Signals; load_initial_config()?; let signals = Signals::new(&[SIGHUP])?; thread::spawn(move || { for signal in &signals { match signal { SIGHUP => { if Err(e) = try_config_reload() { error!("Failed to reload configuration: {}", e); } }, _ => unreachable!(), } } }); Alternatively, the program can have some way to talk to...
News & Blog Posts 2019-08-13 ~13 min read
branan.github.io
...PortName) -> Port { let gate = match port { PortName::B => ClockGate::new(5, 10), PortName::C => ClockGate::new(5, 11), }; if gate.gate.read() != 0 { panic!("Cannot create Port instance; it is already in use"); } gate.gate.write(1); unsafe { Port::new(port, gate) } } } The new ClockGate struct uses the bitband to...
News & Blog Posts 2017-05-09 ~13 min read
paytonrules.com
...Choose a GDNativeLibrary and give it the name rust_library.tres (to match what I have). Select it in the FileSystem after you create it, and you should see the Platform window appear on the bottom of the screen. Add your built library by finding your platform (for me this...
News & Blog Posts 2020-07-08 ~26 min read
www.shuttle.rs
...The Error trait vs Results and enums# One thing when using an enum is we can use match to branch on the enum error variants. On the other hand, with the dyn trait unless you go down the down casting path it is very hard to get specific information about...
Observations/Thoughts 2022-07-06 ~8 min read
fractalfir.github.io
...The compiler does not support 128 bit matches? Cool, a bunch of if’s it is. if val == 0 { // Do sth } else if val == 1{ // Do sth else } else if val == 2{ // Do other thing }/*...*/ else{ // Do yet another thing } Inline causes trouble? Well, out it goes. /*#[inline(always)]*/ // Who...
Observations/Thoughts 2025-07-09 ~22 min read
wangjunfei.com
...For example, when calculating the wire format size of a protocol value, I can use a match statement: 12345678910111213pub fn size(&self) -> i32 { match self { ProtocolType::Bool(bool) => bool.wire_format_size() as i32, ProtocolType::I8(i8) => i8.wire_format_size() as i32, ProtocolType::Array(array) => array.size() as i32...
Rust Walkthroughs 2025-06-25 ~17 min read
blog.veeso.dev
...Command, desc: &str) -> Result<(), String> { println!("running {:?}", command); let status = command.status(); let verbose_error = match status { Ok(status) if status.success() => return Ok(()), Ok(status) => format!( "'{exe}' reported failure with {status}", exe = command.get_program().to_string_lossy() ), Err(failed) => match failed.kind() { std::io::ErrorKind::NotFound => format!( "Command...
Rust Walkthroughs 2025-03-26 ~10 min read
github.com
...Ok(()) } fn main() -> () { use std::process::exit; use libc::{EXIT_SUCCESS, EXIT_FAILURE}; exit(match inner_main() { Ok(_) => EXIT_SUCCESS, Err(ref err) => { let progname = get_program_name(); eprintln!("{}: {}\n", progname, err); EXIT_FAILURE } }) } ``` These problems can be solved by generalizing the return type of `main` and test functions. [csv...
RFC 1937 RFC 2017-02-22 ~21 min read
huonw.github.io
...Option<X>, transformer: ...) -> Option<Y> { match option { Some(x) => Some(transformer(x)), // (closure syntax for now) None => None, } } We need to fill in the ... with something that transforms an X into a Y. The biggest constraint for perfectly replacing Option::map is that it needs to be generic in some...
Notable Links 2015-05-18 ~23 min read
www.tockos.org
...will not compile let external : &mut NumOrPointer; match external { Pointer(internal) => { // This would violate safety and // write to memory at 0xdeadbeef *external = Num(0xdeadbeef); *internal = 12345; // Kaboom }, //... } // Equivalent C // compiles without warning union NumOrPointer* external; uint32_t* numptr = &external->Num; *numptr = 0xdeadbeef; *external->Pointer = 12345; But operating system kernels depend...
News & Blog Posts 2017-08-08 ~8 min read
dwrensha.github.io
...pub mod text { /// Wrapper around utf-8 encoded text. /// This is defined as a tuple struct to allow pattern matching /// on it via byte literals (for example `text::Reader(b"hello")`). #[derive(Copy, Clone, PartialEq)] pub struct Reader<'a>(pub &'a [u8]); impl<'a> Reader<'a> { pub fn as_bytes...
Project/Tooling Updates 2023-09-06 ~3 min read
"I had many questions during the example implementations but "where do I find that" was none of them. [...] Thanks, docs team, you are doing great work..."

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.