docs.rs
...Usage In libraries Libraries should link only to the log crate, and use the provided macros to log whatever information will be useful to downstream consumers: [dependencies] log = "0.4" use log::{info, trace, warn}; pub fn shave_the_yak(yak: &mut Yak) { trace!("Commencing yak shaving"); loop { match find...
Crate
v0.4.35
2026-10-30
doc.rust-lang.org
fn cmp(&self, other: &Self) -> Ordering
...By convention, self.cmp(&other) returns the ordering matching the expression self <operator> other if true.
Examples
use std::cmp::Ordering;
assert_eq!(5.cmp(&10), Ordering::Less);
assert_eq!(10.cmp(&5), Ordering::Greater);
assert_eq!(5.cmp(&5), Ordering::Equal);
method
core
Stable since 1.0.0
Version 1.100.0-nightly
www.nahua.dev
...TokenStream = match &self.col_type {
ColumnType::Char(_)
...
ColumnType::Float(_) => "f32".to_owned(),
ColumnType::Double(_) => "f64".to_owned(),
ColumnType::Json | ColumnType::JsonBinary => "Json".to_owned(),
ColumnType::Date => match date_time_crate {
DateTimeCrate::Chrono => "Date".to_owned(),
DateTimeCrate::Time => "TimeDate".to_owned(),
},
ColumnType::Time(_) => match date_time_crate {
DateTimeCrate::Chrono => "Time".to...
Rust Walkthroughs
2022-06-29
~17 min read
hermanradtke.com
...loop {
match self.sock.try_read_buf(&mut recv_buf) {
// the socket receive buffer is empty, so let's move on
// try_read_buf internally handles WouldBLock here too
Ok(None) => {
debug!("CONN : we read 0 bytes");
break;
},
Ok(Some(n)) => {
debug!("CONN : we read {} bytes", n);
// if we read...
From the Blogosphere
2015-07-27
~7 min read
mainmatter.com
...PdfWriterConfiguration) -> Result<Term, RustlerError> {
match priv_create_pdf(config) {
Ok(()) => Ok(atoms::ok().to_term(env)),
Err(ref error) => return Err(RustlerError::Term(Box::new(io_error_to_term(error)))),
}
}
fn priv_create_pdf(config: PdfWriterConfiguration) -> Result<(), std::io::Error> {}create_pdf is slightly more complicated as it involves some...
Rust Walkthroughs
2023-02-08
~8 min read
rust-lang.github.io
...Attribute invocations can only match the attr rules, and non-attribute invocations can only match the non-attr rules. This allows adding attr rules to an existing macro without breaking backwards compatibility.
An attribute macro may emit code containing another attribute, including one provided by an attribute macro. An attribute...
RFC 3697
RFC
2024-09-20
~7 min read
blog.servo.org
...mattnenterprise updated some older Fetch code to match changes to the specification.
beholdnec fixed a shader problem that was breaking Servo on some AMD drivers.
karenher added support for tracking line numbers in the HTML parser.
canaltinova corrected the serialization of overflow properties in CSS.
hiikezoe made animated colors use...
Other Weeklies from Rust Community
2017-01-10
~2 min read
github.com
...Example use ciborium_ll::{Decoder, Header}; use ciborium_io::Read as _; let input = b"\x6dHello, World!"; let mut decoder = Decoder::from(&input[..]); let mut chunks = 0; match decoder.pull().unwrap() { Header::Text(len) => { let mut segments = decoder.text(len); while let Some(mut segment) = segments.pull().unwrap() { let mut buffer...
Crate
v0.2.2
2024-01-24
rtoch.com
...LinkedList<Vec<Operation>> = LinkedList::new();
stack.push_back(Vec::new());
for token in tokens {
let cur_operations = stack.back_mut().expect("Stack should not be empty!");
match token {
Token::MoveRight => {
if let Some(Operation::MoveRight(x)) = cur_operations.last_mut() {
*x += 1;
} else {
cur_operations.push(Operation::MoveRight(1))
}
}
Token...
Miscellaneous
2022-03-23
~7 min read
jackh726.github.io
...fn transmute_lifetime<'a, 'b, T>(t: &'a (T,)) -> &'b T {
match (&t,) {
((u,),) => u,
}
}
fn main() {
let y = Box::new((42,));
let x = transmute_lifetime(&y);
}
Stable emits the following error:
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
--> src/main.rs:2:11
|
2 | match...
Observations/Thoughts
2022-06-15
~13 min read
smista.ai
...MemoryArgs) -> Result<String, Self::Error> {
let MemoryArgs {
op,
scope,
key,
value,
} = args;
match op {
MemoryOp::Record => {
let value = value.ok_or(MemoryToolError::MissingValue)?;
match scope {
MemoryScope::User => {
self.storage
.put_user_memory(Some(key.clone()), value)
.await?;
}
MemoryScope::Session => {
self.storage
.put_session_memory(Some(key.clone()), value)
.await?;
}
}
Ok...
Rust Walkthroughs
2026-06-17
~7 min read
rust-analyzer.github.io
...during code analysis.
#3722 fix parsing lambdas with return type.
#3724 blame the right queries for memory usage.
#3725 fix TypeScript memory leak on server restart.
#3745 Merge Imports assist correctly handles *.
#3764 fix index out of bounds error during workspace loading.
#3761 Fill Match Arms assist correctly preserves comments.
News & Blog Posts
2020-03-31
~1 min read
rust-analyzer.github.io
#10979 don’t show trait flyimports for impl trait and placeholders.
#10976 show case-insensitive exact matches instead of fuzzy flyimport for short paths.
#10986 fix lint completions not working for unclosed attributes.
#10960 fix handling of macros in extern blocks.
#10957 fix some TryToNav impls not upmapping ranges out...
Project/Tooling Updates
2021-12-15
~1 min read
rust-lang.github.io
...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
integer32.com
...usize) -> Result<&str> {
let s = &s[location..];
match s.find("\n") {
Some(pos) => {
let head = &s[..pos];
Ok((head, location + pos + "\n".len()))
},
None => {
Err(location)
}
}
}
fn main() {
let input = "hello\nworld";
assert_eq!(Ok(("hello", 6)), parse_until_newline(input, 0));
assert_eq!(Err(6), parse_until_newline(input...
News & Blog Posts
2017-02-07
~5 min read
56:25
Rustacean Station
rustacean-station.org
Episode: Idiomatic Rust with Brenden Matthews
...But pattern matching is still great. The only problem is just sometimes you can get really deeply nested or really complicated pattern matches. And I think generally the solution to that is to just not do that. And by not do that, I just mean if your matching is getting...
Podcast
2025-01-04
56:25
rust.code-maven.com
...let database_folder = match std::env::var("DATABASE_PATH") {
Ok(val) => std::path::PathBuf::from(val),
Err(_) => {
let current_dir = std::env::current_dir().unwrap();
current_dir.join("db")
}
};
Connect to the database on the filesystem
Then we connect to the database folder via the RocksDb driver.
let db = Surreal...
Miscellaneous
2024-01-17
~5 min read
rust-analyzer.github.io
...14004 don’t escape non-snippets in Move const to impl.
#14011 fix Unwrap block for let statements.
#14037 handle boolean scrutinees better in Match to if-let assist.
#14039 make Add missing impl members work for impls inside blocks.
#14038 don’t fail workspace loading if sysroot can’t...
Project/Tooling Updates
2023-02-01
~1 min read
doc.rust-lang.org
pub trait Not
...use std::ops::Not;
#[derive(Debug, PartialEq)]
enum Answer {
Yes,
No,
}
impl Not for Answer {
type Output = Self;
fn not(self) -> Self::Output {
match self {
Answer::Yes => Answer::No,
Answer::No => Answer::Yes
}
}
}
assert_eq!(!Answer::Yes, Answer::No);
assert_eq!(!Answer::No, Answer::Yes);
trait
core
Stable since 1.0.0
Version 1.100.0-nightly
info.varnish-software.com
...Let's have a look at that match statement again. I told you it had some nice features, but didn't go too deep about them. One very cool aspect is destructuring, that we'll use. Match is able to give you direct access to element of a struct or...
News & Blog Posts
2016-04-11
~11 min read