system.joekain.com
...modified src/breakpoint/mod.rs
@@ -31,13 +31,13 @@ fn set(inferior: &TrapInferior, bp: &Breakpoint) {
poke_text(inferior.pid, bp.aligned_address, modified);
}
-fn find_breakpoint_matching_inferior_instruction_pointer(inf: &Inferior) -> Option<&Breakpoint> {
+fn find_breakpoint_matching_inferior_instruction_pointer(inf: &TrapInferior) -> Option<&Breakpoint> {
let InferiorPointer(ip) = get_instruction...
Observations/Thoughts
2025-09-03
~38 min read
ceronman.com
...This would require changing the data layout of the structs to match C. The problem with using an enum is that a match operation is required on every dereference. I believe this match should be optimized out by the compiler, but I haven’t properly checked. But even then, struct...
Observations/Thoughts
2021-07-28
~25 min read
kerkour.com
...fn do_something() -> Result<(), Error> {
let user = get_user_opt().ok_or(Error::UserNotFound)?;
// do something
}
match
Then, of course, there is match:
fn do_something() -> Result<(), Error> {
let user = match get_user_opt() {
Some(user) => user,
None => return Err(Error::UserNotFound);
};
// do something
}
if let / let else
Even better...
Observations/Thoughts
2025-11-26
~6 min read
sergey-melnychuk.github.io
...process socket events
for event in &events {
match event.token() {
Token(0) => {
loop {
match listener.accept() {
Ok((socket, _)) => {
// accept connection, create Handler
},
Err(_) => break
}
}
},
token if event.readiness().is_readable() => {
debug!("token {} readable", token.0);
if let Some(handler) = handlers.remove(&token) {
event_tx.send(handler).unwrap();
}
},
token if event...
News & Blog Posts
2020-05-05
~4 min read
system76.com
...System76 offers health benefits, paid vacation, matching 401k, sabbatical, and an awesome dog-friendly work environment where smart people are free to create.
We are committed to providing equal employment opportunities to all employees and applicants, regardless of race, color, creed, religion, sex, gender identity/expression, age, national origin, disabilities...
Rust Jobs
2019-01-08
~1 min read
rustc-dev-guide.rust-lang.org
...Examples of such structures include but are not limited to
• Parenthesis
• Removed without replacement, the tree structure makes order explicit
• for loops
• Converted to match + loop + match
• Universal impl Trait
• Converted to generic arguments (but with some flags, to know that the user didn't write them)
• Existential impl Trait...
Guide to Rustc Development
Book
2024-01-01
~2 min read
trieve.ai
...Our algorithm prioritizes prefix matches and factors in the frequency of each candidate word within the dataset.
fn is_best_correction(word: &str, correction: &str) -> bool {
// Length-based filter
let len_diff = (word.len() as i32 - correction.len() as i32).abs();
if len_diff > 2 {
return false;
}
// Prefix matching (adjust...
Observations/Thoughts
2024-09-11
~6 min read
kerkour.com
...Vec<String>, output_dir: &str) -> Result<(), anyhow::Error> {
let mut html = templates::HEADER.to_owned();
let body = files
.into_iter()
.map(|file| {
let file = file.trim_start_matches(output_dir);
let title = file.trim_start_matches("/").trim_end_matches(".html");
format!(r#"<a href="{}">{}</a>"#, file, title)
})
.collect::<Vec<String...
Rust Walkthroughs
2021-09-29
~3 min read
adventures.michaelfbryan.com
...Value) -> Result<bool, Self::Error> {
match other {
Value::Bool(b) => Ok(b),
_ => Err(Error::BadVariableType),
}
}
}
impl TryFrom<Value> for i32 {
type Error = Error;
fn try_from(other: Value) -> Result<i32, Self::Error> {
match other {
Value::Integer(i) => Ok(i),
_ => Err(Error::BadVariableType),
}
}
}
impl TryFrom<Value> for f64 {
type Error = Error...
News & Blog Posts
2019-12-17
~37 min read
cantrip.org
...On earlier versions of the Rust compiler, I had to use an iterator pipeline, using .scan(), match, .filter(), and .collect(), at twice the line count, to get tolerable performance. Now the loop is faster. A match would work here, but the code would be longer. Rust could have just one...
News & Blog Posts
2016-02-01
~13 min read
esimmler.com
...DomainType<T>,
{
match val {
Val::Var(var) => {
let resolved = self.domain.values_as_ref().get(var);
match resolved {
// We found another Var, try to resolve deeper
Some(found) => self.resolve_val(found),
// We didn't find a binding, return the Var
None => val,
}
}
// This isn't a Var, just return...
News & Blog Posts
2020-07-14
~6 min read
system76.com
...System76 offers health benefits, paid vacation, matching 401k, sabbatical, and an awesome dog-friendly work environment where smart people are free to create.
We are committed to providing equal employment opportunities to all employees and applicants, regardless of race, color, creed, religion, sex, gender identity/expression, age, national origin, disabilities...
Rust Jobs
2020-06-10
~1 min read
blog.urth.org
...Then it generates a CSS file containing just those strings
which match actual Tailwind names.But this scanning process, because it matches so broadly, errs on the side of false positives, and
the tailwindcss program will not emit any warnings when it finds a string that could be a match...
Rust Walkthroughs
2022-02-23
~16 min read
rust-analyzer.github.io
...true
#3580 macro expander is now more tolerant for syntax errors, which makes code completion inside macros more robust.
#3623 Fill Match Arms assist now works even if some arms are already present.
#3607 and instructions for installing rust-analyzer from AUR.
#3640, #3651 assist to merge imports with a...
News & Blog Posts
2020-03-24
~1 min read
dev.to
...This method makes sure that the mock server received exactly one HTTP request that matched all the mock requirements. If not, it will fail the test with a detailed problem description (see next section).
Verification
Mock objects provide an assert method which ensures our app did actually send a request...
Rust Walkthroughs
2020-11-04
~6 min read
www.justanotherdot.com
...macro_rules! time {
($val:expr) => {
{
let beg = std::time::Instant::now();
match $val {
tmp => {
let end = std::time::Instant::now();
let time = (end - beg);
println!("[{}:{}] `{}' took {:?}", std::file!(), std::line!(), std::stringify!($val), time);
tmp
}
}
}
};
($($val:expr),+ $(,)?) => {
($(time!($val)),+,)
};
}
This change uses the repeat pattern matches of macros to consistently...
Observations/Thoughts
2020-08-26
~4 min read
rust-analyzer.github.io
#9936 (first contribution) make compiler commit and date optional in proc macros.
#9962 (first contribution) improve "Replace match with if let" code generation.
#9963 resolve core::arch module.
#9973, #9988 refactor and improve handling of overloaded binary operators.
#9943 don’t strip items with built-in attributes.
#9976 hide functional...
Project/Tooling Updates
2021-08-25
~1 min read
rust-lang-nursery.github.io
...use std::time::Duration;
use tokio::time::timeout;
async fn fetch_network_request() -> u32 {
89
}
#[tokio::main]
async fn main() {
match timeout(Duration::from_millis(5), fetch_network_request()).await {
Ok(x) => println!("Received {x}"),
Err(_) => eprintln!("Timed Out!"),
}
}
Add tokio to Cargo.toml with the macros and time features...
The Rust Cookbook
Book
2024-01-01
~1 min read
matklad.github.io
...u32,
) -> io::Result<Option<Widget>> {
let key = id.to_be_bytes();
let value = match self.db.load(&key)? {
None => return Ok(None),
Some(it) => it,
};
let widget: Widget =
bincode::deserialize(&value).map_err(|it| {
io::Error::new(io::ErrorKind::InvalidData, it)
})?;
Ok(Some(widget))
}
}
Now, for the sake of argument...
Rust Walkthroughs
2022-06-15
~6 min read
rauljordan.com
...Match statements are very flexible and structural in nature
Instead of nesting match statements, for example, one could bring values together as tuples and do
the following:
fn player_outcome(player: &Move, opp: &Move) -> Outcome {
use Move::*;
use Outcome::*;
match (player, opp) {
// Rock moves.
(Rock, Rock) => Draw,
(Rock, Paper) => Lose...
Rust Walkthroughs
2023-01-25
~26 min read