minikin.me
...ComparisonMode) -> bool {
match mode {
ComparisonMode::Strict => self.name == other.name && self.price == other.price,
ComparisonMode::IgnorePrice => self.name == other.name,
}
}
}
fn main() {
let product1 = Product {
name: String::from("Laptop"),
price: 999.99,
};
let product2 = Product {
name: String::from("Laptop"),
price: 999.99, // Same price
};
let product3 = Product {
name: String::from...
Observations/Thoughts
2025-01-29
~4 min read
doc.rust-lang.org
...a>(accounts: &Accounts<'a>,
username: &'a str, password: &'a str){
println!("Username: {}", username);
println!("Password: {}", password);
println!("Attempting logon...");
let logon = Account {
username,
password,
};
match accounts.get(&logon) {
Some(account_info) => {
println!("Successful logon!");
println!("Name: {}", account_info.name);
println!("Email: {}", account_info.email);
},
_ => println!("Login failed!"),
}
}
fn main(){
let...
Rust by Example
Book
2024-01-01
~1 min read
rust-lang.github.io
...Gc<Monster>, room: &mut Room) {
match room.find_random_exit() {
None => { }
Some(exit) => {
victim.move_to_room(exit);
}
}
}
As before, we'll start out with a type of Monster, but this type the method move_to_room() has a receiver type of Gc<Monster>. This doesn't match cases 1...
RFC 48
RFC
2014-06-10
~23 min read
rust.cologne
...labeled break/continue
higher-kinded types
pattern matching in unusual places
path specific visibility
…
We’ll explain a few of them and show example use-cases. If you can think of something that fits the
bill feel free to bring your own examples.
After that we will move to open...
Europe
2023-09-06
~1 min read
blog.yoshuawuyts.com
Tide Channels— 2020-01-29
why channels?
which apis do we need?
channel states
api design
registering a new channel
registering external channel handlers
using channels inside endpoints
matching channels with remote peers
disconnects
heartbeat
interface overview
future directions
group support
http/2 push streams
summary
WebSocket (WS) support for...
News & Blog Posts
2020-01-28
~14 min read
predr.ag
...TL;DR + section index
cargo-semver-checks queries today are slow because many items need to be matched across API versions to their counterparts with the same name. Currently, that's an O(n^2) process (the sweet spot of poor scaling), but can optimized down to O(n).
In...
Observations/Thoughts
2023-02-08
~16 min read
lwn.net
...Kent Overstreet, instead, argued
that the Rust abstractions are a way to design a cleaner interface, and
that this interface should not need to match the C API. Cleaning up the
latter is "a giant hassle" due to the need to change all existing
filesystems at the same time, while...
Project/Tooling Updates
2024-01-31
~7 min read
micouy.github.io
...fn g2(thing: &Thing) -> &String {
&(*thing).field
// ┃ ┗━ Point directly to the referenced data.
// ┗━━━ Create a reference to the expression's value with a matching lifetime.
}
I'm still not sure how Rust determines what lifetime the newly created reference should have. It has been pointed out that *thing is not...
Observations/Thoughts
2022-03-23
~4 min read
www.chiark.greenend.org.uk
...syntax
"Macros by example" macro_rules!
Procedural macros proc_macro
Practicalities
build.rs
Async Rust
Introduction
Fundamentals
Innards
Practicalities
Choosing a runtime
Mixing and matching sync and async; thread context
Pin
Anonymous future types, traits, etc.
Cancellation safety
Send
Error messages
Libraries and utilities
FFI
Raw C FFI
FFI support...
Call for Participation
2021-09-08
~1 min read
heikoseeberger.de
...String) { match MetadataKey::from_bytes(key.as_bytes()) { Ok(key) => match MetadataValue::try_from(&value) { Ok(value) => { self.0.insert(key, value); } Err(error) => warn!(value, error = format!("{error:#}"), "parse metadata value"), }, Err(error) => warn!(key, error = format!("{error:#}"), "parse metadata key"), } }}
With that Injector implementation we can define a...
Rust Walkthroughs
2023-08-30
~3 min read
blog.servo.org
...added support for ARM 32-bit and 64-bit cross-compiles to our CI
kichjang redesigned parts of the script event loop to better match the HTML specification’s task queue concept.
prashant made it possible to choose between EGL and OpenGLES on Linux
rebstar6 enabled click events to be...
News & Blog Posts
2016-03-21
~1 min read
wasmi-labs.github.io
...Slightly slower than its direct counterpart, but has a slightly better memory footprint.Simple but efficient loop-match based instruction dispatch similar to how Wasmi 1.0 dispatch works.Ideally, it will make use of both become keyword,
and #[loop_match] attribute, once those features are stabilized. 13This is just...
Project/Tooling Updates
2025-12-03
~10 min read
slint-ui.com
...Fix some documentation links (#1575)
And add a test in the CI that checks for warnings in the internal
crates
(Also changed --exclude in the test to match the one from build, since
c++ test are run separately)
Remove erroneous mention of SLINT_FEATURE_EVENTLOOP_WINIT_ALL (#1572)
We used...
Project/Tooling Updates
2022-09-07
~4 min read
rust-lang.github.io
...p == p.join(dot)
p == dot.join(p)
p == p.root_path().unwrap_or(dot)
.join(p.relative_path())
p.relative_path() == match p.root_path() {
None => p,
Some(root) => p.path_relative_from(root).unwrap()
}
p == p.dir_path()
.join(p.file_name().unwrap_or(dot))
p == p.iter...
RFC 474
RFC
2014-11-12
~13 min read
doc.rust-lang.org
...Result<i32>) {
match result {
Ok(n) => println!("The first doubled is {}", n),
Err(e) => println!("Error: {}", e),
}
}
fn main() {
let numbers = vec!["42", "93", "18"];
let empty = vec![];
let strings = vec!["tofu", "93", "18"];
print(double_first(numbers));
print(double_first(empty));
print(double_first(strings));
}
Rust by Example
Book
2024-01-01
~1 min read
dawchihliou.github.io
...VecDeque<&mut BinaryTree<T>> = VecDeque::new();
queue.push_front(self);
loop {
let BinaryTree {
ref mut left,
ref mut right,
..
} = queue.pop_back().unwrap();
match left {
Some(node) => {
queue.push_front(node);
}
None => {
*left = Some(Box::new(BinaryTree::new(new_value)));
return;
}
}
match right {
Some(node) => {
queue.push_front(node);
}
None...
Observations/Thoughts
2022-01-19
~9 min read
rust-java-tutorials.netlify.app
...this will collide with other impl Ridable that happen to match Bicycle
// ...
#[test]
fn take_a_ride_test(){
let mut bike = BasicBicycle::default();
bike.take_a_ride();
assert!(bike.get_speed() == 10);
}
Note that in current stable rust (version 1.5.3), looks like rust doesn't allow to define...
Observations/Thoughts
2021-07-07
~4 min read
fast.github.io
...That matches a lot of failures.
But some of the nastiest problems aren’t a single line of causality. Validation can fail in five places at once. A batch operation can partially succeed. Timeouts can come with partial results. Those want something closer to a set or a tree of...
Rust Walkthroughs
2026-01-07
~9 min read
jamesmcm.github.io
...Auto Ref in pattern matching
I couldn’t find an RFC for this, but it’d great to be able to use a
static &str when matching on an enum containing a String. i.e. so
this would be possible:
enum MyEnum {
WithString(String),
Other,
}
fn main() {
let myenum = MyEnum...
Call for Blog Posts
2020-09-30
~10 min read
rust-lang.github.io
...A pattern Foo { .. } can match more things than just the expression Foo { .. }, because the pattern matches any value of the unmentioned fields, but the expression sets them to a particular value. This means that, with the unstable inline_const_pat, the arm const { Foo { .. } } => matches less than the arm Foo...
RFC 3681
RFC
2024-08-22
~44 min read