dev.to
...Notice that the parameters are specified in <> and they must match the parameter names of the function.
the function returns a String with the body of the page.
lastly, in main(), we "ignite" the rocket engine (that is we start it), and we mount any route to it. After this...
Rust Walkthroughs
2020-11-04
~6 min read
github.com
...The following is valid:
```rust
let packed_cast = &raw const packed.field;
```
## Reference-level explanation
[reference-level-explanation]: #reference-level-explanation
Rust contains two operators that perform place-to-value conversion (matching `&` in C): one to create a reference (with some given mutability) and one to create a raw pointer...
RFC 2582
RFC
2018-11-01
~11 min read
alonely0.github.io
...enum CellValue {
Num(f64),
Str(ThinVec<u8>),
Formula(Rc<Formula>),
Iter(Box<dyn Iterator<Item = CellValue>>),
}
impl Display for CellValue {
fn fmt(&self, f: ...) -> ... {
match self {
Self::Num(x) => x.fmt(f),
Self::Str(s) => s.fmt(f),
Self::Formula(o) => o.fmt(f),
Self::Iter(i) => todo!(),
}
}
}
The todo...
Observations/Thoughts
2024-05-01
~11 min read
hermanradtke.com
...fn tick(&mut self, event_loop: &mut EventLoop<Server>) {
trace!("Handling end of tick");
let mut reset_tokens = Vec::new();
for c in self.conns.iter() {
if c.is_reset() {
reset_tokens.push(c.token);
}
}
for token in reset_tokens {
match self.conns.remove(token) {
Some(_c) => {
debug!("reset connection...
News & Blog Posts
2015-10-26
~7 min read
blog.sheerluck.dev
...fn log_oneline(commits: &HashMap<String, Commit>, start_hash: &str) {
let mut hash = start_hash.to_string();
loop {
match commits.get(&hash) {
Some(commit) => {
let short_hash = &hash[..7];
let first_line = commit.message.lines().next().unwrap_or("");
println!("{} {}", short_hash, first_line);
match commit.parent_hashes.first() {
Some(parent...
Rust Walkthroughs
2026-05-27
~22 min read
rvarago.github.io
...From Vec<T> into IndexedVec<T, N> if N matches the run-time length of Vec<T>.
impl<T, N: Nat> TryFrom<Vec<T>> for IndexedVec<T, N> {
type Error = (); // TODO: Use a better error type.
fn try_from(value: Vec<T>) -> Result<Self, Self::Error> {
if value.len() == N...
Observations/Thoughts
2025-02-26
~2 min read
trifectatech.org
...u64;
match operation {
1 => {
*value += 10 as libc::c_int;
current_block_1 = 4407541767199398248;
}
2 => {
current_block_1 = 4407541767199398248;
}
_ => {
current_block_1 = 12675440807659640239;
}
}
match current_block_1 {
4407541767199398248 => {
*value *= 2 as libc::c_int;
}
_ => {}
};
}
We can try to find some better names for the labels, but otherwise it's not...
Rust Walkthroughs
2025-03-12
~11 min read
codeinput.com
...Though I knew from the start that each editor would need its own integration, the pattern matching logic for CODEOWNERS rules stays the same across all of them; and it was important that this code produce consistent results whether it ran in Lua or Rust.
So the challenge was twofold...
Rust Walkthroughs
2026-03-25
~6 min read
dev.to
...The UI never blocks — it just renders whatever state it has and updates when events arrive.
// Sending a query from UI thread
let _ = self.db_tx.send(DbCommand::Execute(sql));
// Receiving results in the same UI update loop
while let Ok(event) = self.db_rx.try_recv() {
match event {
DbEvent...
Project/Tooling Updates
2026-03-25
~2 min read
github.com
...As an example, imagine a function that converts strings to their corresponding
booleans.
```rust
const fn parse_bool(s: &str) -> bool {
match s {
"true" => true,
"false" => false,
other => panic!("`{}` is not a valid bool", other),
}
}
parse_bool("true");
parse_bool("false");
parse_bool("foo");
```
will produce an error with your...
RFC 2345
RFC
2018-02-22
~2 min read
linebender.org
...Using it has trade-offs around bandwidth usage in CI, but otherwise matches our use-case perfectly.
The demo for the stroke expansion paper, which was created using Xilem Web.
An interactive version can be found on the paper's website.
Parley
Parley is a text layout library.
Nico Burns...
Project/Tooling Updates
2024-08-14
~2 min read
github.com
...satisfied wherever the struct or enum is used with actual type parameters.
## Motivation
Makes type checking saner. Catches errors earlier in the development process.
Matches behaviour with built-in bounds (I think).
Currently formal type variables in traits and functions may have bounds and
these bounds are checked whenever the...
RFC 34
RFC
2014-04-05
~3 min read
github.com
...Eventually, we will likely want to support fully general pattern matching just
like in `let` bindings (e.g., `const (a, b): (u8, u8) = (1, 1)`) to not have
`const _` be a special case in the language. However, this RFC leaves the
details of such a design up to a future...
RFC 2526
RFC
2018-08-18
~3 min read
poignardazur.github.io
...The (T, ...Ts) syntax that lets our trait impl match tuples with at least one element.
The (head, ...tail) syntax that lets us destructure our tuple and get a tail tuple.
Already we can make some DX observations:
We replaced an iterative loop with a tail-recursive loop (well, almost...
Observations/Thoughts
2025-07-16
~19 min read
blog.joco.dev
...Arc<Mutex<HashMap<String, User>>>,
) -> Result<impl warp::Reply, warp::Rejection> {
let users = db.lock().await;
match users.get(&credentials.username) {
None => Ok(StatusCode::BAD_REQUEST),
Some(user) => {
if credentials.password == user.password {
Ok(StatusCode::OK)
} else {
Ok(StatusCode::UNAUTHORIZED)
}
}
}
}
This function takes the given credentials and checks to see...
News & Blog Posts
2019-12-03
~6 min read
dev.to
...Here are representative host functions you’ll see in pallet-revive-uapi (names match the HostFn surface):
Host Function
Purpose
set_storage / get_storage
Write/read contract storage (key/value).
call / instantiate
Call another contract / deploy a new contract instance.
deposit_event
Emit an event (topics + data).
caller / origin
Get...
Rust Walkthroughs
2026-02-18
~11 min read
arzg.github.io
...TokenKind) -> Self {
match token_kind {
TokenKind::Whitespace => Self::Whitespace,
TokenKind::FnKw => Self::FnKw,
TokenKind::LetKw => Self::LetKw,
TokenKind::Ident => Self::Ident,
TokenKind::Number => Self::Number,
TokenKind::Plus => Self::Plus,
TokenKind::Minus => Self::Minus,
TokenKind::Star => Self::Star,
TokenKind::Slash => Self::Slash,
TokenKind::Equals => Self::Equals,
TokenKind::LParen => Self::LParen,
TokenKind...
Rust Walkthroughs
2020-12-23
~10 min read
fitzgeraldnick.com
...fn foo() -> impl Future<Output = ()> {
use std::future;
use std::pin::Pin;
use std::task::Poll;
future::from_generator(move || {
// Awaiting `task::sleep`.
{
let mut pinned = task::sleep(<Duration>::from_millis(100));
loop {
match future::poll_with_tls_context(unsafe {
Pin::new_unchecked(&mut pinned)
}) {
Poll::Ready(()) => break,
Poll::Pending...
News & Blog Posts
2019-08-27
~7 min read
gruebelinchen.wordpress.com
...ContactFormMessage) = event.payload()? else { return Ok(Response::builder() .status(StatusCode::BAD_REQUEST) .body("Could not extract message payload".into()) .unwrap()); }; match self.process_message(message).await { Ok(_) => Ok(Response::builder() .status(StatusCode::OK) .body("Message sent".into()) .unwrap()), Err(_) => Ok(Response::builder() .status(StatusCode::INTERNAL_SERVER_ERROR) .body("Could not...
Rust Walkthroughs
2023-12-13
~6 min read
blog.veeso.dev
...Future, { let mut f = unsafe { Pin::new_unchecked(&mut f) }; let thread = std::thread::current(); let waker = Arc::new(SimpleWaker { thread }).into(); let mut ctx = Context::from_waker(&waker); loop { println!("polling future"); match f.as_mut().poll(&mut ctx) { Poll::Ready(val) => { println!("future is ready"); return val; } Poll...
Observations/Thoughts
2025-03-19
~6 min read