Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
siciarz.net
...extern crate postgres; use postgres::{Connection, SslMode}; fn main() { let dsn = "postgresql://rust:rust@localhost/rust"; let conn = match Connection::connect(dsn, &SslMode::None) { Ok(conn) => conn, Err(e) => { println!("Connection error: {}", e); return; } }; } The Connection type has a few methods related to making queries; perhaps the simplest one is...
24 Days of Rust continues! 2014-12-15 ~3 min read
blog.kolo.app
...It only has support for a limited number of types, which don't match Python's data types amazingly well. Maybe it was time to try a different format. In particular, msgpack was looking attractive: It is a binary format which optimises for size. It supports many of the basic...
Rust Walkthroughs 2023-10-11 ~8 min read
rocket.rs
...Routes without query parameters now match requests with or without query parameters. Default rankings prefer static paths and routes with query string matches. A native Accept header structure was added. The Accept request header can be retrieved via Request::accept(). All active routes can be retrieved via Rocket::routes(). Response...
News & Blog Posts 2017-07-18 ~7 min read
briankung.dev
...As mentioned before, not_whitespace will match any character that isn’t whitespace, whereas space1 will match a single space and space0 will match zero or one space. But a few of these are custom parsers that I wrote from nom’s more basic building blocks: pinyin, jyutping, and definitions...
Rust Walkthroughs 2021-12-22 ~11 min read
github.com
...cannot move out of borrowed content --> /Users/jturner/Source/errors/borrowck-move-out-of-vec-tail.rs:30:17 I’m trying to track the ownership of the contents of `tail`, which is borrowed, through this match statement: 29 | match tail { In this match, you use an expression of the...
RFC 1644 RFC 2016-06-07 ~13 min read
rust-analyzer.github.io
...Your browser does not support the video tag. #12345 (first contribution) add escapeSequence semantic token type. #12263 hide type inlay hints for let statements that initialize a closure (enable using rust-analyzer.inlayHints.typeHints.hideClosureInitialization): #12130 add assist to turn let-else statements into let and match: Your browser does...
Project/Tooling Updates 2022-05-25 ~1 min read
doc.rust-lang.org
...Default, { match map.get_mut(&key) { Some(value) => value, None => { map.insert(key.clone(), V::default()); map.get_mut(&key).unwrap() } } } Because of the lifetime restrictions imposed, &mut map's lifetime overlaps other mutable borrows, resulting in a compile error: error[E0499]: cannot borrow `*map` as mutable more than once...
The Rustonomicon Book 2024-01-01 ~2 min read
rust-analyzer.github.io
#3084 better error reporting around workspace loading. #3102 better error reporting when deserializing wrong config. #3092 fix error when starting the server immediately after download. #3100 improved error handling when downloading the server binary. #3114 fix type inference for match arms of unknown type. #3121 during auto-import, don’t...
News & Blog Posts 2020-02-18 ~1 min read
redox-os.org
...Redox was not matching POSIX behavior for file descriptors; when dup is called, the new fd should still refer to the same “file description”, which Redox did not have a concept of. I modified the kernel to match POSIX behavior. I changed Redox’s target triple (for the gcc toolchain...
News & Blog Posts 2017-08-22 ~4 min read
antoinerr.github.io
...match failing_function() { Ok(s) => println!("{s}"), Err(e) => match e.downcast_ref() { Some(MyErrors::LetsFixThisTomorrowError) => (), Some(MyErrors::ThisDoesntLookGoodError) => (), Some(MyErrors::ImmaGetFiredError) => (), None => (), }, } Returning early with an error Finally, anyhow provides a utility macro to return early from your methods with an error: the bail! macro. Here is how it...
Rust Walkthroughs 2023-02-01 ~6 min read
doc.rust-lang.org
...In that regard, macro_rules! can work similarly to a match block: // `test!` will compare `$left` and `$right` // in different ways depending on how you invoke it: macro_rules! test { // Arguments don't need to be separated by a comma. // Any template can be used! ($left:expr; and $right:expr...
Rust by Example Book 2024-01-01 ~1 min read
speakerdeck.com
Transcript ALGEBRAIC DATA TYPES enum Color { Red, Green, Blue } enum Tree { Empty, Leaf(int), Node(~Tree, ~Tree) } tag tag int tag ~Tree ~Tree Empty Leaf(int) Node(~Tree, ~Tree) PATTERN MATCHING enum Option<T> { None, Some(T) } fn double(p: ~int) -> int { *p * 2 } OWNERSHIP void *realloc(void *, ...); void free...
Discussion + Blog posts 2013-07-29 ~1 min read
ryan-jacobs1.github.io
...fn cleanup() { let me = smp::me(); let mut cleanup_work = CLEANUP[me].lock(); loop { match cleanup_work.get_task() { Some(work) => {work()}, None => {break} } } } Now we can finish our implementation of surrender and move on to block: pub fn surrender() { let mut current_thread: Box<dyn TCB> = match swap_active...
News & Blog Posts 2020-01-14 ~9 min read
arzg.github.io
...Option<ast::Expr>) -> Expr { if let Some(ast) = ast { match ast { // snip ast::Expr::VariableRef(ast) => Expr::VariableRef { var: ast.name().unwrap().text().into(), }, } } else { // snip } } // snip } That match arm is longer than one line; let’s extract it to a method for consistency:impl Database { // snip pub(crate) fn...
Rust Walkthroughs 2021-01-27 ~18 min read
blog.turbo.fish
...Figuring out what's inside is a simple manner of matching: use syn::{Data, DataStruct, Fields}; let fields = match input.data { Data::Struct(DataStruct { fields: Fields::Named(fields), .. }) => fields.named, _ => panic!("this derive macro only works on structs with named fields"), }; Here, we panic!() if the input is not what...
Rust Walkthroughs 2021-02-24 ~12 min read
brson.github.io
...Linked error-chain errors are able to propagate backtraces and have a structural shape that is easy to deeply match, so that e.g. your error that originated in your utils crate, bubbled through your net crate, then up through your app crate is easy to pinpoint through pattern matching...
News & Blog Posts 2016-12-06 ~6 min read
nikolish.in
...Self::Message) { match message { CounterMessage::Increment => self.count += 1, CounterMessage::Decrement => self.count -= 1, CounterMessage::ChangePage(view) => self.current_view = view }} We simple update the state of our application by assigning the current_view with the view that is passed by the message. We now need to somehow produce this...
Observations/Thoughts 2022-06-22 ~7 min read
rust-analyzer.github.io
...emit fewer download progress notifications. #7419, #7422 unquote strings when expanding concat!. #7438 shorten hir::TypeParam ranges for traits in NavigationTarget. #7406 don’t assume happy path in if_let_match. #7464 export CARGO for proc. macros. #7465 only hide parameter hints for path, field and methodcall expressions. #7487 forbid...
Project/Tooling Updates 2021-02-03 ~1 min read
rust-analyzer.github.io
#13805 (first contribution) complete enum variants without parens when snippets are disabled. #13794 fix "parser seems stuck" panics when parsing colossal files. #13795 use the correct edition when formatting code in path dependencies. #13800 don’t match let expressions and inline consts in expr MBE fragments. #13820 fix binding mode...
Project/Tooling Updates 2022-12-28 ~1 min read
rust-analyzer.github.io
...boxed slices (~2 MB win on analysis-stats self). #14151 enable smallvec's union feature (~4 MB win on analysis-stats self). #14156 don’t reconstruct ref match completion in to_proto manually. #14165 make CompletionItem more POD-like. #14147 don’t rely on VSCode internal commands in the server.
Project/Tooling Updates 2023-02-22 ~1 min read
"The long compile times where all responsibility is taken away from you is infinitely more effective than submission patterns in BDSM, where the gracef..."

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.