github.com
...When combined with `#[repr(C)]` the size alignment and layout of the struct
should match the equivalent struct in C.
`#[repr(packed)]` and `#[repr(packed = "1")]` should have identical behavior.
Because this lowers the effective alignment of fields in the same way that
`#[repr(packed)]` does (which caused [issue #27060...
RFC 1399
RFC
2015-12-06
~3 min read
blog.sheerluck.dev
...The router receives the request and efficiently matches the request path against the registered routes. The pattern /{code} matches /abc12345, captures the path segment, verifies the HTTP method is GET, and selects the redirect handler.
Handler extraction: Before calling redirect, Axum runs the extractors. State<AppState> clones the Arc (cheap...
Rust Walkthroughs
2026-07-08
~20 min read
code.visualstudio.com
...implicit declaration of function ‘prinft’ [-Wimplicit-function-declaration]
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
// The first match group matches the file name which is relative.
"file": 1,
// The second match group matches the line on which the problem occurred.
"line": 2,
// The third match group matches the column at...
News & Blog Posts
2017-04-11
~21 min read
blog.sylver.dev
...0,
}
}
pub fn next_record(&mut self) -> Option<anyhow::Result<Cursor>> {
let page = match self.pager.read_page(self.page) {
Ok(page) => page,
Err(e) => return Some(Err(e)),
};
match page {
Page::TableLeaf(leaf) => {
let cell = leaf.cells.get(self.cell)?;
let header = match parse_record_header(&cell.payload) {
Ok...
Rust Walkthroughs
2024-07-24
~13 min read
blog.thomasheartman.com
...nested OR-patterns and trait aliases.Nested OR-patternsThis was mentioned as an upcoming feature in the post Recent and future pattern matching improvements from the Inside Rust Blog in March. In short, it allows you to nest patterns when pattern matching.Imagine you have an Option<u8> and you...
Call for Blog Posts
2020-09-30
~4 min read
epage.github.io
...Spawn Failed
Assertion Failed
Status (success / failure) Failed
Exit Code Failed
Output
Strings matched when shouldn't
Strings matched when should
Bytes matched when shouldn't
Bytes matched when should
Sub-strings matched when shouldn't
Sub-strings matched when should
Byte subset matched when shouldn't
Byte subset matched...
News & Blog Posts
2018-03-13
~10 min read
blog.jonaylor.xyz
...Lazy<RegexSet> = Lazy::new(|| {
RegexSet::new(RULES.iter().map(|&(_, regex)| regex))
.expect("All regexes should be valid")
});
let matches = REGEX_SET.matches(blob);
if !matches.matched_any() {
return None;
}
Some(matches.iter().map(|i| RULES[i].0).collect())
}
And with the find_secrets() function done, we can go ahead and...
Rust Walkthroughs
2021-11-10
~9 min read
docs.rs
...Here's a simple example that matches a date in YYYY-MM-DD format and prints the year, month and day: use regex_lite::Regex; fn main() { let re = Regex::new(r"(?x) (?P<year>\d{4}) # the year - (?P<month>\d{2}) # the month - (?P<day>\d{2}) # the...
Crate
v0.1.9
2026-02-03
doc.rust-lang.org
Destructuring
A match block can destructure items in a variety of ways.
• Destructuring Tuples
• Destructuring Arrays and Slices
• Destructuring Enums
• Destructuring Pointers
• Destructuring Structures
See also:
The Rust Reference for Destructuring
Rust by Example
Book
2024-01-01
~1 min read
crates.io
...let parser = parser.map(|event| match event { Event::SoftBreak => Event::HardBreak, _ => event }); Or expanding an abbreviation in text: let parser = parser.map(|event| match event { Event::Text(text) => Event::Text(text.replace("abbr", "abbreviation").into()), _ => event }); Another simple example is code to determine the max nesting level: let mut max...
Crate
v0.13.4
2026-05-20
github.com
...r##"
> An "or" pattern was used where the variable bindings are not consistently bound
> across patterns.
>
> Example of erroneous code:
>
> ```compile_fail
> let x = (0, 2);
> match x {
> (0, ref y) | (y, 0) => { /* use y */} // error: variable `y` is bound with
> // different mode in pattern #2
> // than in pattern #1...
RFC 1567
RFC
2016-01-04
~3 min read
quickwit.io
...All documents matching this query must also match the query tenant_id=57.
Quickwit will only search into the splits with 57 within their tenant_id values.Finally, we entirely revamped our indexing pipeline.By default, it now emits splits every sixty seconds.
The pipeline also transparently takes care of...
Project/Tooling Updates
2022-01-19
~6 min read
dev.to
...fn normalize_next_url(next: &str, base: &str) -> String {
let path_and_query = match next.find("://") {
Some(scheme_end) => {
let after_scheme = &next[scheme_end + 3..];
match after_scheme.find('/') {
Some(path_start) => &after_scheme[path_start..],
None => "/",
}
}
None => next,
};
format!("{}{}", base, path_and_query)
}
Enter fullscreen mode
Exit fullscreen...
Rust Walkthroughs
2026-07-22
~3 min read
crates.io
GraphQL introspection query and response types. graphql-introspection-query This crate defines structs implementing serde::Deserialize that match the shape returned by a spec-compliant GraphQL API presented with the introspection query.
Crate
v0.3.0
2025-12-08
github.com
...F) -> U {
match self {
Some(t) => f(t),
None => Default::default(),
}
}
}
```
The following implementation would get added to `core::result::Result`:
```rust
impl<T, E> Result<T, E> {
pub fn map_or_default<U: Default, F: FnOnce(T) -> U>(self, f: F) -> U {
match self {
Ok(t) => f(t),
Err...
RFC 3148
RFC
2021-07-14
~1 min read
joelmccracken.github.io
...use std::fs::File;
fn log_something(filename, string) {
let mut f = try!(File::create(filename));
try!(f.write_all(string));
}
fn main() {
match log_something("log.txt", "ITS ALIVE!!!") {
Ok(..) => println!("File created!"),
Err(..) => println!("Error: could not create file.")
}
}
=>
$ cargo run
Compiling simple-log v0.1.0 (file...
Notable Links
2015-06-07
~6 min read
aloso.github.io
...impl<It> Node<It> { fn traverse(&self) { match self { Node::Leaf(_) => {} Node::Children(children) => { for node in children { node.traverse(); } } } }}
If we want to do something with each item, we can pass a closure to the function:
impl<It> Node<It> { fn traverse(&self, f: impl Fn(&It)) { match self...
Rust Walkthroughs
2021-03-10
~7 min read
pksunkara.com
...Rails
match 'orgs', to: 'orgs#create', via: [:post, :put]
Django
path('orgs', views.orgs.create),@require_http_methods(["POST", "PUT"])
def create(request):
pass
Laravel
<?php
Route::match(['post', 'put'], 'orgs', 'OrgsController@create');
Actix
app.service(
resource("orgs")
.route(post().to(orgs::create))
.route(put().to(orgs::create))
);
Cons
This...
News & Blog Posts
2020-05-19
~8 min read
erickt.github.io
...Token) -> Result<Point, E> {
try!(state.expect_struct_start(token, "Point"));
let mut x = None;
let mut y = None;
loop {
let idx = match try!(state.expect_struct_field_or_end(&["x", "y"])) {
Some(idx) => idx,
None => { break ; }
};
match idx {
Some(0us) => { x = Some(try!(state.expect_struct_value())); }
Some(1us...
Project Updates
2015-02-16
~4 min read
github.com
...0.3.8 Tracking upstream to match version 0.7.1 Recommended to upgrade from 0.3.7 to get an important bug fix. 0.3.7 Tracking upstream to match version 0.7 0.3.4 Tracking upstream to version 0.6.2. 0.3.3 Tracking upstream to...
Crate
v0.7.5
2026-08-12