rust-lang.github.io
...Then during compilation, this information is used at the proper places rather than matching against an enum listing the OSes we recognize. The target_os, target_family, and target_arch cfg variables would be extracted from the --target passed to rustc.
Drawbacks
More complexity. However, this is very flexible and...
RFC 131
RFC
2014-06-18
~3 min read
sixtyfps.io
...Ideally we'd link to the crate documentation that
(1) perfect matches the version number (2) uses sixtyfps.io for our built docs and docs.rs for the published crates
I could not find a way to do this (not without making the crate a dependency and adding features), so...
Project/Tooling Updates
2022-01-19
~3 min read
rustc-dev-guide.rust-lang.org
...These references are used for example in the find_in_move_path_or_its_descendants function, which determines whether a move-path (e.g., a.b) or any child of that move-path (e.g.,a.b.c) matches a given predicate.
Guide to Rustc Development
Book
2024-01-01
~3 min read
www.arroyo.dev
...So we’ll dig into how arrow-json works and then talk through Arroyo’s extensions to support raw JSON—leaving parts of the JSON serialized—and the ability to skip records in a batch that don’t match the schema. Along the way you should pick up some intuition...
Observations/Thoughts
2025-03-05
~18 min read
benw.is
...The key here is that the part after the colon matches your world defined in the wit file.
TOML markup[package.metadata.component]
package = "benwis:femark"
[package.metadata.component.dependencies]
and then setting up the wit bindings. WASI2 defines functions and types that are exported and imported from other components...
Observations/Thoughts
2024-03-20
~17 min read
rust-lang.github.io
...operator will follow Deref impls to try to find a matching function. This can lead to really confusing compiler errors, or code "spuriously compiling" but doing something unexpected because there was an unexpected match somewhere in the Deref chain. This is why many of Rc's operations are static functions...
RFC 1966
RFC
2015-08-01
~8 min read
polyfractal.com
...use std::io::prelude::*;
use std::io::{BufReader, BufWriter};
use std::fs::File;
fn main() {
match File::open("/data/foo.txt") {
Ok(f) => {
let mut reader = BufReader::new(f);
let mut buffer = String::new();
reader.read_line(&mut buffer).unwrap();
println!("{}", buffer);
},
Err(e) => println!("ERROR: {}", e)
}
match File::create...
News & Blog Posts
2015-11-16
~8 min read
www.ncameron.org
...So most functions return Results, and in code where you don't care about error handling, that means a lot of unwraps.Rust IO strives to be performant, and that means it is low-level, matching OS IO primitives as closely as possible. It means that the user allocates buffers...
Project/Tooling Updates
2022-01-05
~3 min read
www.lpalmieri.com
...fn fallible_operation() -> Result<String, String> { ... }
pub fn main() {
match fallible_operation() {
Ok(success) => {
log::info!("Operation succeeded: {}", success);
}
Err(err) => {
log::error!("Operation failed: {}", err);
}
}
}
We are trying to perform an operation that might fail.
If it succeeds, we emit an info-level log record.
If it doesn't...
Learn More Rust
2020-09-30
~53 min read
blog.stillinbeta.com
...It's very simple to use! You just create a normal struct,
add a few annotations when the JSON object doesn't quite match Rust's conventions,
and derive Deserialize. Magic!
Here's our struct:
Listing 2: bus.rs#[derive(Deserialize, Debug, Clone)]
struct Route {
#[serde(rename = "RouteNo")]
route_no...
Rust Walkthroughs
2024-01-10
~13 min read
hoverbear.org
...https://github.com/james-darkfox/rs-wrapped_enum-macro
wrapped_enum!{
#[derive(Debug)]
pub enum Error {
CapnProto(capnp::Error),
SchemaError(capnp::NotInSchema),
Io(io::Error),
Raft(RaftError),
}
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Error::CapnProto(ref error) => fmt::Display::fmt...
New Releases & Project Updates
2015-07-20
~3 min read
slint.dev
...Adapt your custom controls to match the selected widget style with the new Palette singleton.
Programmatically show a slint::Window fullscreen with the new set_fullscreen(bool) function. (Thanks qhua948)
Keep the event loop alive when there are no windows with new run_event_loop_until_quit() function. This is...
Project/Tooling Updates
2024-01-31
~3 min read
deno.land
...Due to some non-public work happening to use the Deno infrastructure, we began
the effort to break the Deno system up into smaller “op crates” which could be
mixed and matched to produce custom V8 runtimes. First steps were taken towards
this in August, and the deno_web crate...
Project/Tooling Updates
2021-01-20
~8 min read
dev-state.com
...messages
let mut message_stream = consumer.receive().await?;
while let Some(message) = message_stream.next().await {
match message {
Ok(stream_message) => {
let payload = stream_message.messages;
// Deserialize the message using the schema
match serde_json::from_slice::<MyMessage>(&payload) {
Ok(decoded_message) => {
println!("Received message: {:?}", decoded_message);
}
Err(e) => {
eprintln...
Project/Tooling Updates
2024-07-03
~7 min read
diziet.dreamwidth.org
...Rust insists that match statements are
exhaustive, meaning that each one covers all the possibilities.
So if you left out the line with the _, it wouldn't
compile.
Rust enums can also be marked non_exhaustive, which is
a declaration by the API designer that they plan to add more...
Observations/Thoughts
2021-09-22
~9 min read
www.badykov.com
...a single worker. Otherwise, the same task will be processed several times. It was achieved using for update skip locked in the select query:
match fang_tasks::table
.order(fang_tasks::created_at.asc())
.limit(1)
.filter(fang_tasks::state.eq(FangTaskState::New))
.for_update()
.skip_locked()
.get_result::<Task...
Project/Tooling Updates
2021-06-30
~3 min read
marketplace.visualstudio.com
...Patterns support comma-separated lists and can match file or folder names.
Advanced Configuration: Conditional Compilation (cfg)
For projects that require conditional compilation, you can use the cfg key. It accepts a comma-separated list of conditions. Automod will generate a mod declaration for each condition.
Example .rautomod:
# This rule...
Project/Tooling Updates
2025-09-10
~3 min read
jamesmcm.github.io
...for addr in 1..=127 {
esp_println::println!("Scanning Address {}", addr as u8);
let res = i2c.read(addr as u8, &mut [0]);
match res {
Ok(_) => esp_println::println!("Device Found at Address {}", addr as u8),
Err(_) => esp_println::println!("No Device Found"),
}
}
This helped me notice that the I2C pins...
Rust Walkthroughs
2024-11-06
~8 min read
hassamuddin.com
...If it is, we respond.
// src/main.rs
loop {
match framed.next().await {
Some(Ok(PingRequest)) => {
framed.send(PingResponse).await;
println!("Ping - Pong!")
},
_ => {
println!("Received an unknown packet");
break;
}
}
}
Now our program will keep running forever, at least until you try to use it. But it’s progress; we’ve...
News & Blog Posts
2020-07-21
~8 min read
rustc-dev-guide.rust-lang.org
...Developers use existing LLVM coverage analysis tools to decode .profraw files, with corresponding Coverage Maps (from matching binaries that produced them), and generate various reports for analysis, for example:
Screenshot of sample llvm-cov show result, for function add_quoted_string
Detailed instructions and examples are documented in the rustc...
Guide to Rustc Development
Book
2024-01-01
~3 min read