jtjlehi.github.io
...Option<AddStrsError> = None;
// we could use `unwrap_or_default` but I think 0 is more clear here
let u1 = match s1.parse() {
Ok(val) => val,
Err(err) => {
ret_err = Some(/* map the error */);
0
}
};
let u2 = match s2.parse() {
Ok(val) => val,
Err(err) => {
ret_err = Some(/* map the error...
Observations/Thoughts
2026-07-01
~9 min read
www.ncameron.org
...There is no Rust type that matches these semantics and has the required layout in memory. Therefore we must use a two step process.
First, we use a newtype wrapping an integer. This is used as a field in a data structure, etc., so that when we take a view...
News & Blog Posts
2016-01-18
~13 min read
rust-lang-nursery.github.io
...String) -> Result<Self, String> {
let level = match value.to_lowercase().as_str() {
"info" => LogLevel::Info,
"debug" => LogLevel::Debug,
"warn" => LogLevel::Warn,
"error" => LogLevel::Error,
"trace" => LogLevel::Trace,
other => return Err(format!("Unknown log level: {}", other)),
};
Ok(level)
}
}
#[allow(dead_code)]
#[derive(Debug)]
struct Config {
server_url: String,
log_level: LogLevel...
The Rust Cookbook
Book
2024-01-01
~2 min read
www.cmyr.net
...this ended up being much harder than I expected it to be, partly because
of important differences in the behaviour of the two languages, and partly
because of the (self-imposed) obligation to match an existing (idiomatic) python
API.
Motivation
Python is the traditional language of choice for font tools...
Observations/Thoughts
2021-05-19
~12 min read
matthewkmayer.github.io
...impl Error for CreateQueueError {
fn description(&self) -> &str {
match *self {
CreateQueueError::QueueDeletedRecently(ref cause) => cause,
CreateQueueError::QueueNameExists(ref cause) => cause,
CreateQueueError::Validation(ref cause) => cause,
CreateQueueError::Credentials(ref err) => err.description(),
CreateQueueError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
CreateQueueError::Unknown(ref cause) => cause
}
}
}
And after:
impl Error for CreateQueueError...
News & Blog Posts
2017-06-27
~5 min read
patriksvensson.se
Archived: primary link replaced with an archive on 2026-09-12T16:30:35.113Z (UTC; replacement date, not snapshot date)
...RECT};
use winapi::um::winuser::{EnumDisplayMonitors, GetMonitorInfoW, MONITORINFOEXW};
fn main() {
for monitor in enumerate_monitors() {
// Convert the WCHAR[] to a unicode OsString
let name = match &monitor.szDevice[..].iter().position(|c| *c == 0) {
Some(len) => OsString::from_wide(&monitor.szDevice[0..*len]),
None => OsString::from_wide(&monitor.szDevice[0..monitor.szDevice...
News & Blog Posts
2020-06-10
~2 min read
dev.to
...openai-oxide, a Rust client that matches the official Python SDK's API surface, with persistent WebSockets, structured outputs, and WASM deployment that aren't available in other Rust clients.
Why Not Just Use What Exists?
My goal was a Rust client with complete 1:1 parity with the official...
Observations/Thoughts
2026-04-01
~9 min read
www.joshmatthews.net
...C header files
The next step was writing a header file that matched the public types and functions exposed by my low-level bindings (like an inverse bindgen). This was a straightforward application of writing out function prototypes that match, since all of the types I expose are opaque structs...
News & Blog Posts
2015-10-19
~5 min read
rust-lang.github.io
...Vec<_> = iter::repeat(elem).take(n).collect();
None of these quite match the convenience, power, and performance of:
let vec = Vec::from_elem(elem, n)
• #1 is verbose and slow, because each push requires a capacity check.
• #2 only works for a Copy elem and const n.
• #3 needs a...
RFC 832
RFC
2015-02-11
~2 min read
lonami.dev
...i32 = ...;
let target = target.to_ne_bytes();
locations.retain(|addr| match process.read_memory(*addr, target.len()) {
Ok(memory) => memory == target,
Err(_) => false,
});
println!("Now have {} locations", locations.len());
We create a vector to store all the locations the first scan finds, and then retain those that match a second...
Miscellaneous
2021-02-17
~19 min read
www.fluvio.io
...All this to say, we are now back on
track with matching versions in the client/server builds.
In addition to these compatibility fixes, 0.9.2 also included some internal fixes
to the Streaming Processing Units (SPUs) that should make them more reliable when being
deployed in a Kubernetes...
Project/Tooling Updates
2021-08-18
~2 min read
www.byronwasti.com
...Currently, Balter's control loops for error rate matching and latency matching are slow. By polling more often, the control loops would be run more often and Balter would be faster at converging to a specified error rate or latency. However, we don't want to provide bad data to...
Observations/Thoughts
2024-05-29
~5 min read
lab.whitequark.org
...EthernetProtocolType::Ipv4 => {
let ip_packet = try!(Ipv4Packet::new(eth_frame.payload()));
match try!(Ipv4Repr::parse(&ip_packet)) {
// ...
Ipv4Repr { protocol: InternetProtocolType::Udp, src_addr, dst_addr } => {
let udp_packet = try!(UdpPacket::new(ip_packet.payload()));
udp_payload = udp_packet.data();
}
},
EthernetProtocolType::Ipv6 => {
let ip_packet = try!(Ipv6Packet::new(eth_frame.payload...
News & Blog Posts
2016-12-20
~9 min read
rust-gpu.github.io
...Look at other commit messages and
match the format. Match the style of other Rust shader commits. Include the
lockfile."
I would just paste those lines back in from the golden prompt. So, Claude was
effectively "three-shotting" the task. I think it was forgetting due to a small context...
Rust Walkthroughs
2025-06-25
~9 min read
rustc-dev-guide.rust-lang.org
...Requirements
• LLVM libraries must be available in your system's library search paths
• The LLVM version must match the one used to build your Rust toolchain
Troubleshooting steps
1. Verify LLVM is installed and accessible
2. Ensure that library paths are set:
export LD_LIBRARY_PATH=/path/to/llvm/lib...
Guide to Rustc Development
Book
2024-01-01
~2 min read
www.atriiy.dev
...Match imports with exports
With all module exports resolved, the next step is to match each import to its corresponding export. This entire process is managed using the data and structures encapsulated within the BindImportsAndExportsContext.
struct BindImportsAndExportsContext<'a> {
pub index_modules: &'a IndexModules,
pub metas: &'a mut LinkingMetadataVec,
pub symbol...
Miscellaneous
2025-06-18
~23 min read
guillaumegomez.github.io
...Recent doc contributions
@QuietMisdreavus updated formatting of fn signatures and where clauses to match style rfcs in rustdoc.
@estebank added an explicit help message for binop type mismatch, added end line display of multiline annotations and used proper span for tuple index parsed as float.
@frewsxcv made a couple minor...
News & Blog Posts
2017-04-18
~2 min read
www.sea-ql.org
...loop { match ws.next().await { Some(Ok(Message::Text(data))) => { if data == r#"{"event":"heartbeat"}"# { continue; } println!("{data}"); } Some(Err(e)) => bail!("Socket error: {e}"), None => bail!("Stream ended"), e => bail!("Unexpected message {e:?}"), }}
2. Redis / Kafka Stream Producer
Step 1, create a SeaStreamer instance connecting to Redis / Kafka:
let...
Rust Walkthroughs
2024-05-08
~5 min read
fasterthanli.me
...we never use `sleep` anymore, and `socket` is `Unpin`
std::mem::swap(unsafe { self.as_mut().get_unchecked_mut() }, &mut state);
match state {
Acceptor::Waiting { socket, .. } => {
// necessary to avoid closing the socket on drop
std::mem::forget(socket)
}
_ => unreachable!(),
};
match unsafe { self.get_unchecked_mut() } {
Acceptor::Listening { ln } => {
let (stream...
Rust Walkthroughs
2022-04-06
~41 min read
natkr.com
...PlayTrick<'a>,
},
}
impl<'a> SimpleFuture<()> for TrickOrTreat<'a> {
fn poll(&mut self) -> Poll<()> {
loop {
match self {
TrickOrTreat::Init => {
let house = House {
street: "Riksgatan".to_string(),
house_number: 3,
};
*self = TrickOrTreat::DemandTreat {
house,
demand_treat: DemandTreat {
house: &house,
}
};
}
_ => todo!(),
}
}
}
}
error[E0597]: `house` does not live long enough
--> src/main.rs:76...
Observations/Thoughts
2025-05-28
~20 min read