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
docs.babelmonkeys.de
...use xml::{Event, Parser}; // Create a new Parser let mut p = Parser::new(); // Feed data to be parsed p.feed_str("<a href"); p.feed_str("='//example.com'/>"); // Get events for the fed data for event in p { match event.unwrap() { Event::ElementStart(tag) => println!("<{}>", tag.name), Event::ElementEnd(tag...
Crate
v0.3.0
2020-03-08
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
blog.urth.org
...That’s because I’m using Rust’s
enum-based pattern matching. The Node enum has over 100 variants. That’s a lot of matching!I also need to generate enum wrappers around many structs. Any time a struct references another
struct, I need the wrapper indirection. So for example...
Observations/Thoughts
2021-03-17
~9 min read
blog.cloudflare.com
...right hand side is parsed and used as a byte sequence (will match a URL "/1234567")Are there other examples of such ambiguities? Yup - for example, we can try using a single number with two decimal digits:tcp.port == 80: matches any traffic on the port 80 (HTTP)http.file...
News & Blog Posts
2019-03-05
~17 min read
github.com
...As such, the lang team will need to approve the high-level answer.
- **Do match guards have semantic meaning?**
Match guards are inserted by the compiler around match statements to ensure that if guards cannot change the value being matched on. Whether match guards should exist at all primarily affects...
RFC 3346
RFC
2022-11-07
~8 min read
ettolrach.com
...Expr::App(l, m) => match infer(*l, context)? {
Type::Arrow(a, b) => match check(*m.clone(), *a, context) {
Ok(_) => Ok(*b),
Err(TypeError {
kind:
ErrorKind::CheckedWrongType {
expected: a,
actual,
},
line,
column,
}) => Err(TypeError {
kind: ErrorKind::ArgWrongType {
expected: a,
actual,
},
line,
column,
}),
Err(e) => Err(e),
},
actual => Err(TypeError {
kind: ErrorKind...
Observations/Thoughts
2025-12-31
~15 min read