rust-analyzer.github.io
#10608 (first contribution) amend the rustup installation instructions.
#10574, #10578 fix "Generate PartialOrd implementation" codegen.
#10568 improve codegen for "Unwrap Result return type".
#10585 resolve derive attributes even when shadowed.
#10587 fix add_missing_match_arm panicking on failed upmapping.
#10589 expand unused glob import into {}.
#10594 generate and complete...
Project/Tooling Updates
2021-10-27
~1 min read
doc.rust-lang.org
pub fn unbound() -> io::Result<UnixDatagram>
UnixDatagram::unbound — Creates a Unix Datagram socket which is not bound to any address.
Examples
use std::os::unix::net::UnixDatagram;
let sock = match UnixDatagram::unbound() {
Ok(sock) => sock,
Err(e) => {
println!("Couldn't unbound: {e:?}");
return
}
};
associated_function
std
Stable since 1.10.0
Version 1.100.0-nightly
blog.sebastiansastre.co
...In our snippet, the Suspend arm does what handle_suspend does; the match is already a branch. A match on an enum compiles to a jump table or a chain of comparisons. You’ve already paid for a branch. Adding a function call inside one arm adds roughly one more...
Observations/Thoughts
2026-03-11
~7 min read
pwy.io
...calling `.city.to_owned()` here is inefficient, because it
// will allocate a new string even if the hashmap already contains
// the entry; this can be avoided with `.raw_entry_mut()`, but
// let's not go crazy
}
Self { indexed_prices }
}
/// Returns indices of prices matching given city and occupancy.
fn find...
Observations/Thoughts
2024-10-16
~5 min read
neosmart.net
...ignore-result for rust Safely ignore errors in function return values when the result isn't critical This crate adds a .ignore() function to Result instances that ignores both the Ok and Err variants of the result, silencing compiler warnings about unused errors without needing to resort to empty match...
Crate
v0.2.0
2018-12-24
hugopeixoto.net
...Applying the same thresholding and connected pixels detection to this template,
I could find the one that more closely matched the digit being detected using
Template Matching. In short, this algorithm goes through each pixel
inside the bounding box of both the template and the digit, finds how many
pixels...
Rust Walkthroughs
2022-03-16
~7 min read
doc.rust-lang.org
pub fn bind<P>(path: P) -> io::Result<UnixListener>
UnixListener::bind — Creates a new UnixListener bound to the specified socket.
Examples
use std::os::unix::net::UnixListener;
let listener = match UnixListener::bind("/path/to/the/socket") {
Ok(sock) => sock,
Err(e) => {
println!("Couldn't connect: {e:?}");
return
}
};
associated_function
std
Stable since 1.10.0
Version 1.100.0-nightly
rust-analyzer.github.io
...trying to use an uncached syntax node in Semantics.
#10460 only add proc_macro to prelude in proc-macro crates.
#10477 fix parsing of macro call inside generic args.
#10449 fix parsing of Some(1..).
#10420 parse outer attributes on StructPatternEtCetera.
#10480 change snake case fix to match rustc implementation.
Project/Tooling Updates
2021-10-13
~1 min read
dev.to
...Option<String> = Option::None;
loop {
std::thread::sleep(time::Duration::from_secs(1));
println!("Waiting for event...");
let evt = next_event(&client, &r.extension_id);
if let Some(req_id) = prev_request.take() {
process_result(req_id);
}
match evt {
Ok(evt) => match evt {
NextEventResponse::Invoke {
request_id,
deadline_ms,
..
} => {
println...
Rust Walkthroughs
2020-11-04
~10 min read
FOSDEM
video.fosdem.org
...Some of these are fundamental novelties, and others are optimizations matching the changing performance landscape in modern hardware. In this talk we present Glidesort, a general purpose in-memory stable comparison sort. It is fully adaptive to both pre-sorted runs in the data similar to Timsort, and low-cardinality...
Talk
Orson Peters
2023-02-04
crates.io
...Linux, Windows, MacOS, FreeBSD, OpenBSD, illumos Example use mac_address::get_mac_address; fn main() { match get_mac_address() { Ok(Some(ma)) => { println!("MAC addr = {}", ma); println!("bytes = {:?}", ma.bytes()); } Ok(None) => println!("No MAC address found."), Err(e) => println!("{:?}", e), } } License mac_address is licensed under both MIT and...
Crate
v1.2.1
2026-10-11
doc.rust-lang.org
pub fn bind<P>(path: P) -> io::Result<UnixDatagram>
UnixDatagram::bind — Creates a Unix datagram socket bound to the given path.
Examples
use std::os::unix::net::UnixDatagram;
let sock = match UnixDatagram::bind("/path/to/the/socket") {
Ok(sock) => sock,
Err(e) => {
println!("Couldn't bind: {e:?}");
return
}
};
associated_function
std
Stable since 1.10.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn pair() -> io::Result<(UnixDatagram, UnixDatagram)>
UnixDatagram::pair — Creates an unnamed pair of connected sockets.
Returns two UnixDatagramss which are connected to each other.
Examples
use std::os::unix::net::UnixDatagram;
let (sock1, sock2) = match UnixDatagram::pair() {
Ok((sock1, sock2)) => (sock1, sock2),
Err(e) => {
println!("Couldn't unbound: {e:?}");
return
}
};
associated_function
std
Stable since 1.10.0
Version 1.100.0-nightly
blog.logrocket.com
...To handle an enum in Rust, you have to match on it. Every time you match on an enum, the compiler makes sure you’re handling all the variants. Not handling a variant is a compile-time error unless you explicitly opt into this behavior using _ => ....
#[must_use]
Types and...
Learn Standard Rust
2020-08-04
~11 min read
manishearth.github.io
...enum Foo {
Str(String),
Bool(bool)
}
let foo = Foo::Bool(true);
// "pattern matching"
match foo {
Str(s) => /* do something with string `s` */,
Bool(b) => /* do something with bool `b` */,
}
Swift is similar, and also calls them enums
enum Foo {
case str(String)
case boolean(bool)
}
let foo = Foo.boolean(true...
News & Blog Posts
2017-03-07
~9 min read
rust-lang.github.io
...In the MIR, all drops are explicit, including those that result from panics and unwinding.
• How matches are desugared. Reasoning about matches has been a traditional source of complexity. Matches combine traversing types with borrows, moves, and all sorts of other things, depending on the precise patterns in use. This...
RFC 1211
RFC
2015-07-14
~27 min read
doc.rust-lang.org
...valid in the following conditions as well as the consequent block.
•
match arms bindings are within the match guard and the match arm expression.
•
match guard let bindings are valid in the following guard conditions and the match arm expression.
Local variable scopes do not extend into item declarations.
Pattern...
The Rust Reference
Book
2024-01-01
~8 min read
rust-analyzer.github.io
#12382 make auto-closing angle brackets configurable, disabled by default.
#12341 make files.excludeDirs work.
#12355 fix inference when pattern matching a tuple field with a wildcard.
#12409 fix overflow during type inference for tuple struct patterns.
#12384, #12386 Generate variant: insert code in file with enum definition.
#12370 insert...
Project/Tooling Updates
2022-06-01
~1 min read
doc.rust-lang.org
...We’ll also define a new function to match the new function defined on Box<T>.
We define a struct named MyBox and declare a generic parameter T because we want our type to hold values of any type. The MyBox type is a tuple struct with one element of...
The Rust Programming Language
Book
2024-02-01
~9 min read