Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
kerkour.com
...While in Rust, a non-exhaustive match produces a compile-time error: #[derive(Debug, Clone, Copy)] enum Platform { Linux, MacOS, Windows, Unknown, } impl fmt::Display for Platform { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { Platform::Linux => write!(f, "Linux"), Platform::Macos => write!(f, "macOS"), // Compile time...
Observations/Thoughts 2026-04-01 ~6 min read
kerkour.com
...Q, user: &User) -> Result<(), Error> { const QUERY: &str = "INSERT INTO users (id, email) VALUES ($1, $2)"; sqlx::query(QUERY) .bind(user.id) .bind(&user.email) .execute(db) .await .map_err(|err| match err { sqlx::Error::Database(db_err) if db_err.constraint().is_some() => Error::EmailAlreadyInUse, err => Error::Unspecified(format...
Observations/Thoughts 2026-08-12 ~9 min read
m4rw3r.github.io
...I| { let m = i.mark(); match f.parse(i) { (b, Ok(d)) => (b, Ok(d)), (b, Err(_)) => g.parse(b.restore(m)), } } } It is almost identical to the monad-like definition: pub fn or<I: Input, T, E, F, G>(i: I, f: F, g: G) -> ParseResult<I, T, E...
News & Blog Posts 2016-08-30 ~5 min read
doc.rust-lang.org
...It is undefined behavior to (unsafely) construct an instance of an enum that does not match one of its variants. (This allows exhaustive matches to continue to be written and compiled as normal.) repr(transparent) #[repr(transparent)] can only be used on a struct or single-variant enum that has...
The Rustonomicon Book 2024-01-01 ~6 min read
lab.whitequark.org
...1 2 3 4 5 6 7 8 9 10 11 12 13 pub enum Address { Invalid, Ipv4([u8; 4]) } impl Address { pub fn is_invalid(&self) -> bool { match self { &Address::Invalid => true, _ => false } } } The API should: Permit reading addresses; Permit replacing addresses; Permit appending addresses, if used with a...
News & Blog Posts 2016-12-20 ~14 min read
bitrust.octarineparrot.com
...SomeType = ...; match foo { SOME_CONST => ... } ``` Another good option is to rewrite the match arm to use an `if` condition (this is also particularly good for floating point types, which implement `PartialEq` but not `Eq`): ```rust match foo { c if c == SOME_CONST => ... } ``` Finally, a third alternative is to tag the...
What 2014-12-08 ~46 min read
lwn.net
...The kernel API makes lock implementations matching that convention available. For example, a Mutex actually contains the data that it protects, so that it can ensure all accesses to the data are made with the Mutex locked. Since C code doesn't tend to work like this, the kernel's...
Project/Tooling Updates 2025-07-23 ~10 min read
www.sea-ql.org
...how do you actually enforce those rules against SQL queries? With an external library, we still need to analyze raw SQL statements ourselves and match that up with the rule definitions. By embedding RBAC directly into SeaORM, we can analyze all queries and enforce those rules. Lightweight and performant Because...
Project/Tooling Updates 2025-10-01 ~9 min read
dev.to
...Comic::print This should be a simple addition, all we need to do is match on the OutFormat and print the Comic representation appropriately. Let's stub that out: impl Comic { // .. snip fn print(&self, of: OutFormat) -> Result<()> { match of { OutFormat::Text => println!("{}", todo!("print self as Text")), OutFormat::Json...
Rust Walkthroughs 2021-01-06 ~17 min read
fasterthanli.me
...Subcommand, } #[derive(FromArgs)] #[argh(subcommand)] enum Subcommand { Sample(sample::Sample), } impl Subcommand { fn run(self) { match self { Subcommand::Sample(x) => x.run(), } } } fn main() { // see https://turbo.fish/ argh::from_env::<Args>().subcommand.run(); } // in `src/sample.rs` use argh::FromArgs; #[derive(FromArgs)] /// Run sample code #[argh(subcommand, name...
News & Blog Posts 2020-07-08 ~23 min read
www.hacklewayne.com
...It doesn't stop here, pattern matching / case split takes another form, match (a, b) { (None, None) => "Both missing", (_, _) => "Something is there", } Come on, make up your mind! (Ok I am sure there are good reasons for these decisions but seriously was it really necessary to be this confusing?) closure...
Rust Walkthroughs 2022-03-02 ~10 min read
lwn.net
...The if let syntax matches x against the pattern Some(v), binding the name v to the SleepOnDrop value inside x whenever one is present. The else clause applies when x is None. Put together, the function is just an elaborate way to write the identity function: it returns whatever...
Project/Tooling Updates 2025-10-01 ~10 min read
guillaumegomez.github.io
...refer to add_two as “tested function”. @ConnyOnny updted match enum warning in The Book. @Wilfred added missing URL to release notes. @Eijebong fixed minor typo. @utkarshkukreti replaced all try! with ? in documentation examples. @GuillaumeGomez added missing urls for OsStr and OsString, forced backline on all where in docs, removed...
Other Weeklies from Rust Community 2017-01-31 ~2 min read
www.thecodedmessage.com
...let input = match from_slice(&input) { Ok(parsed_value) => parsed_value, // This is the parsed value, type `Value` Err(_) => input, // This is the raw `Vec<u8>` data... TYPE MISMATCH! } We are then forced to brainstorm another solution, which might raise ideas we didn’t otherwise consider, and force us to...
Rust Walkthroughs 2022-09-21 ~6 min read
www.florianreinhard.de
...We will encrypt a small „Hello World!“ message, give it a rough sanity check, and then we decrypt it back and hope, that the decrypted output matches our input. Under ./tests/features, please create the file encryptor.feature. The containing test specification should roughly look like this: Feature: Encrypt messages...
Learn Simple Rust 2020-09-30 ~10 min read
guillaumegomez.github.io
...a dereference. @mikhail-m1 improved “Doesn’t live long enough” error. @liigo marked unsafe fns in module page with superscript icons in rustdoc. @xfix matched guessing game output to newest language version. @steveklabnik made it clear that the reference isn’t normative. @joshtriplett documented convention for using both fmt::Write...
Other Weeklies from Rust Community 2016-11-08 ~2 min read
c410-f3r.github.io
...The recurring stumbling block is that Intermediate CAs or Root CAs need a Subject Key Identifier and if an Authority Key Identifier extension exists in a self-signed certificate, it must match the SKI. CERTS_DIR="$(dirname $0)/../.certs" openssl genpkey -algorithm ed25519 -out $CERTS_DIR/key.pem openssl req...
Observations/Thoughts 2026-07-29 ~8 min read
fengsp.github.io
...fn search(request: &mut Request) -> PencilResult { let keyword = match request.args().get("q") { Some(q) => q as &str, None => "", }; Ok(Response::from(format!("You are searching for {}", keyword))) } fn main() { // app here app.get("/search", "search", search); } Before/After Request extern crate typemap; use typemap::Key; struct KeyType; struct Value...
Notable New Crates & Project Updates 2016-03-14 ~2 min read
gergo.erdi.hu
...So my idea was to rewrite that in Rust, mainly aiming to use Rust's algebraic data type support with pattern matching. Given the way one usually programs microcontrollers, I think pattern matching gives me the most bang for my buck for now, until we start designing and implementing funky...
News & Blog Posts 2017-05-16 ~6 min read
www.infoq.com
...Do we really want to check every possible type of input? Do we want to add a new match for while expressions, and loop, and ... you get the point. The Fold trait The syn library has an advanced tool for use cases like this one, where we want to go...
Rust Walkthroughs 2024-03-13 ~10 min read
"A Box always holds exactly one thing, like a single large struct. A Vec holds zero to many things of exactly one type and can change over time. If you..."

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.