aidancully.blogspot.com
...Pin<&mut BarGenerator>, cx: &mut Context<'_>) ->
GeneratorState<() /* yield type */, usize /* result type */>
{
loop {
match vars {
Variant1 { ref var1 } => {
let var2 = &var1;
let await_point = baz();
*vars = Variant2 { var1, var2, await_point };
}
Variant2 { ref var1, ref var2, ref await_point } => {
match Pin::new_unchecked(&mut await_point).poll(&mut cx) {
Poll...
Observations/Thoughts
2022-08-10
~5 min read
cfallin.org
...This function is essentially just a large match
statement over the opcode of the root CLIF instruction, with the match-arms
looking deeper as needed.
Here is a simplified version of the match-arm for an integer add operation
lowered to AArch64 (the full version is
here):
match op {
// ...
Opcode...
Observations/Thoughts
2020-09-23
~25 min read
blog.burntsushi.net
...Vec<StateID>,
// Whether a particular state ID corresponds to a match state.
// Guaranteed to have length equal to the number of states.
is_match_id: Vec<bool>,
}
impl DFA {
// Returns true if the DFA matches the entire 'haystack'.
// This routine always returns either true or false for all inputs.
// It...
Observations/Thoughts
2022-08-10
~33 min read
rustc-dev-guide.rust-lang.org
...In the names->numbers phase, if the query has only one name in it, the editDistance function is used to find a near match if the exact match fails, but if there's multiple items in the query, non-matching items are treated as generics instead. This means hahsmap will...
Guide to Rustc Development
Book
2024-01-01
~16 min read
steveklabnik.com
...u32 = match guess.trim().parse() {
Ok(num) => num,
Err(_) => continue,
};
println!("You guessed: {}", guess);
match guess.cmp(&secret_number) {
Ordering::Less => println!("Too small!"),
Ordering::Greater => println!("Too big!"),
Ordering::Equal => {
println!("You win!");
break;
}
}
}
}
We aren’t quite properly re-using the buffer here, but we could modify this...
Learn Simple Rust
2020-10-21
~4 min read
matthewkmayer.github.io
...pub fn is_commit_event(&self) -> bool {
self.is_accepted_pr() || self.is_direct_push_event()
}
pub fn is_accepted_pr(&self) -> bool {
if self.event_type != "PullRequestEvent" {
return false;
}
match self.payload {
Some(ref payload) => match payload.pull_request {
Some(ref pr) => match pr.merged {
Some(merged) => merged,
None...
Learn
2020-07-28
~11 min read
rust-analyzer.github.io
Fixes
#13749 don’t show duplicated adjustment hints for blocks, ifs and matches.
#13742 only shift BoundVars that come from outside lowering context (fixes a crash with GATs).
#13750 normalize projection after discarding free BoundVars in RPIT (fixes a crash during normalization).
Project/Tooling Updates
2022-12-14
~1 min read
siciarz.net
...u8) -> OpCode {
match opcode {
0 => OpCode::Continue,
1 => OpCode::Text,
2 => OpCode::Binary,
8 => OpCode::Close,
9 => OpCode::Ping,
10 => OpCode::Pong,
_ => OpCode::Reserved,
}
}
}
#[derive(Debug)]
struct WebSocketFrame {
fin: bool,
opcode: OpCode,
mask: bool,
length: u64,
masking_key: u16,
payload: Vec<u8>,
}
We're using a custom enum to make...
24 Days of Rust
2016-12-13
~5 min read
doc.rust-lang.org
...invalid lifetime parameter name: `'static`
fn invalid_lifetime_parameter<'static>(s: &'static str) -> &'static str { s }
•
safe is used for functions and statics, which has meaning in external blocks.
•
raw is used for raw borrow operators, and is only a keyword when matching a raw borrow operator form (such as...
The Rust Reference
Book
2024-01-01
~2 min read
rust-lang.github.io
...And requiring matching on every
use of the type is less ergonomic. For example, the clamp RFC would
naturally use a RangeInclusive parameter, but because it still needs
to assert!(start <= end) in the NonEmpty arm, the noise of the Empty
vs NonEmpty match provides it no value.
a...b...
Updates from Rust Core
2018-03-20
~5 min read
lazy.codes
...match x { 1 + 3 => {} } results in a syntax error while match x { const { 1 + 3 } => {} }does not.
if_let_guard
Extends the if guards that you can use with match statements to be able to use if let.
let_chains
Currently, if let and while let expressions can not be...
Rust Walkthroughs
2021-07-28
~18 min read
dev.to
...if let Some(e) = err.find::<Error>()
Enter fullscreen mode
Exit fullscreen mode
In such case, we'll match each and every Error branch and return an appropriate response. Matching against ValidationError will extract validation errors and serialize them as part of request. In a real world scenario, you'd...
Rust Walkthroughs
2021-01-27
~4 min read
github.com
...Rc<[Wrap]> = Rc::from(arr.as_ref());
/// assert_eq!(rc.as_ref(), &arr); // The elements match.
/// assert_eq!(rc.len(), arr.len()); // The lengths match.
/// ```
///
/// Using the [`Into`][Into] trait:
///
/// ```
/// #![feature(shared_from_slice)]
/// use std::rc::Rc;
///
/// #[derive(PartialEq, Clone, Debug)]
/// struct Wrap(u8);
///
/// let rc: Rc<[Wrap]> = arr...
RFC 1845
RFC
2017-01-05
~12 min read
github.com
...And requiring matching on every
use of the type is less ergonomic. For example, the clamp RFC would
naturally use a `RangeInclusive` parameter, but because it still needs
to `assert!(start <= end)` in the `NonEmpty` arm, the noise of the `Empty`
vs `NonEmpty` match provides it no value.
- `a...b...
RFC 1192
RFC
2015-07-07
~5 min read
developer.ibm.com
...In this context, I match _f against the possible error values (Ok and Err). For Ok, I return the file for assignment; for Err, I use panic!.
use std::fs::File;
fn main() {
let _f = File::open("file.txt");
let _f = match _f {
Ok(file) => file,
Err(why) => panic!("Error...
Observations/Thoughts
2021-01-06
~11 min read
github.com
...A filter option evaluates to `true` if the corresponding generic parameter in the trait definition matches the specified type. The provided `message`/`note`/`label` options are only emitted if the filter operation evaluates to `true`.
The `any` and `all` options allow to combine multiple filter options. The `any` option matches...
RFC 3368
RFC
2023-01-06
~10 min read
smallcultfollowing.com
...It’s at least kind of scary.On a related note, right now, because match code is built into the
compiler, we allow it to inspect freely without worrying about
whether data is mutably borrowed or not. We know, after all, that
during a match the only possibility for side...
Announcements etc
2013-11-19
~13 min read
github.com
## Summary
Add simple syntax for accessing values within tuples and tuple structs behind a
feature gate.
## Motivation
Right now accessing fields of tuples and tuple structs is incredibly painful—one
must rely on pattern-matching alone to extract values. This became such a
problem that twelve traits were created in...
RFC 184
RFC
2014-07-24
~1 min read
brson.github.io
...util
canvas->azure
canvas->geom
canvas->cssparser
canvas->gleam
canvas->num
offscreen_gl_context
offscreen_gl_context
canvas->offscreen_gl_context
cssparser->encoding
matches
matches
cssparser->matches
gleam->libc
gl_common
gl_common
gleam->gl_common
gl_generator
gl_generator
gleam->gl_generator
khronos_api
khronos_api
gleam->khronos_api...
Notable Links
2015-05-18
~3 min read
thunderseethe.dev
...comb.goal.clone(),
})
} else {
None
}
});
match poss_uni {
// Unify if we have a match
Some(match_comb) => {
self.unify_row_row(new_comb.left, match_comb.left)?;
self.unify_row_row(new_comb.right, match_comb.right)?;
self.unify_row_row(new_comb.goal, match_comb.goal)?;
}
// Otherwise add our...
Observations/Thoughts
2023-10-25
~29 min read