blog.katona.me
...termion::event::Event) -> Event { }}impl Iterator for MappedIter<'_> { type Item = Event; fn next(&mut self) -> Option<Event> { match self.source.next() { None => None, Some(result) => Some(self.map_input(result.unwrap())), } }}
So far so good. I have a working “iterator-mapper” constructed with a basic ownership model. InputSource gets constructed...
News & Blog Posts
2019-12-31
~6 min read
nitschinger.at
...if you try to return the array in the match arms rust will complain that the match arms have different array sizes. So the workaround by jamwaffles is to always return a byte array with the same length, but then pass a slice of the correct size to the display...
Rust Walkthroughs
2020-11-18
~12 min read
kbknapp.dev
...Comic::print
This should be a simple addition, all we need to do is match on the
OutFormat and print the Comic representation appropriately.
Let's stub that out:
impl Comic {
// .. snip
fn print(&self, of: OutFormat) -> Result<()> {
match of {
OutFormat::Text => println!("{}", todo!("print self as Text")),
OutFormat::Json...
News & Blog Posts
2020-06-23
~17 min read
gitlab.com
...Command = match it.next()), but nothing prevents you from implementing some additional logic (like transliterating, for instance) there! :)
And yes, I don't think it makes sense to transliterate stuff using regular expressions :)
Call for Participation
2020-05-12
~2 min read
zelanton.github.io
...The classifier sees the typed error — you can match on the exit code,
an Error::Timeout, or the captured stderr. A cancelled run is never retried:
the token stays cancelled.
CancellationToken (re-exported from tokio-util) is the coordinated
shutdown primitive. Wire the same parent token into many jobs via...
Project/Tooling Updates
2026-06-17
~9 min read
rust-lang.github.io
...for x in it.take(3) { // a *copy* of the iterator is used here
// ..
}
match it.next() { // the original iterator (not advanced) is used here
// ..
}
However, there is considerable demand for Copy range types for multiple reasons:
ergonomic use without needing explicit .clone()s or rewriting the a..b syntax...
Updates from the Rust Project
2024-07-10
~16 min read
branan.github.io
...u32) -> Fbe {
let osc = self.mcg.c2.read().get_bits(4..6);
let frdiv = if osc == OscRange::Low as u8 {
match divide {
1 => 0,
2 => 1,
4 => 2,
8 => 3,
16 => 4,
32 => 5,
64 => 6,
128 => 7,
_ => panic!("Invalid external clock divider: {}", divide)
}
} else {
match divide {
32 => 0,
64...
News & Blog Posts
2017-02-07
~20 min read
www.poor.dev
...String) -> RawFd {
unimplemented!()
}
fn main() {
let default_shell = std::env::var("SHELL")
.expect("could not find default shell from $SHELL");
let stdout_fd = spawn_pty_with_shell(default_shell);
let mut read_buffer = vec![];
loop {
match read_from_fd(stdout_fd) {
Some(mut read_bytes) => {
read_buffer.append(&mut read...
Rust Walkthroughs
2021-11-03
~19 min read
blog.japaric.io
...The
app::foo function shown above doesn’t match either format.
Now let’s see what cargo-call-stack produces when it uses both signature
matching and name matching. This is the rest of the program:
struct Bar;
// uses the default method implementation
impl Foo for Bar {}
struct Baz;
impl...
News & Blog Posts
2019-03-19
~44 min read
github.com
...https://rust-lang.github.io/rfcs/3058-try-trait-v2.html
```rust
match Try::branch(x) {
ControlFlow::Continue(v) => v,
ControlFlow::Break(r) => break 'try FromResidual::from_residual(r),
}
```
Where `'try` means the synthetic label added to the innermost enclosing `try` block.
(The actual label is not something that can...
RFC 3721
RFC
2024-02-22
~20 min read
branan.github.io
...Clock) {
unsafe {
match clock {
Clock::PortC => {
let mut scgc = core::ptr::read_volatile(&self.scgc5);
scgc |= 0x00000800;
core::ptr::write_volatile(&mut self.scgc5, scgc);
}
}
}
}
}
The simple match-based clock management we have here would get
unwieldy pretty quickly if we intended to use it to manage a large
number...
News & Blog Posts
2017-01-17
~21 min read
doc.rust-lang.org
...This is mostly relevant to macros. E.g. quote!{ #a#b } is no longer accepted.
• It doesn't treat keywords specially, so e.g. match"..." {} is no longer accepted.
• Insert whitespace between the identifier and the subsequent #, ", or ' to avoid errors.
• Edition migrations will help you insert whitespace in such...
The Rust Edition Guide
Book
2024-01-01
~2 min read
www.vectorware.com
...The abstraction is only zero cost when the vector width
matches the number of warp lanes.
Not every cross-lane operation maps to an efficient warp instruction. Shuffles that match
the hardware's supported patterns are cheap, but arbitrary permutations may need several
instructions or a trip through shared memory...
Observations/Thoughts
2026-08-12
~9 min read
smallcultfollowing.com
...The snippet doesn’t include the HIR, but it includes a number of methods like lower_ty that take as input an AST type and produce the HIR type:impl Context {
fn lower_ty(&mut self, ty: &ast::Ty) -> hir::Ty {
match ty {
// ... lots of stuff here
// A type like...
Observations/Thoughts
2022-06-22
~13 min read
ticki.github.io
...If not, we get the non-matching value, which
allows us to handle things case-by-case.
Searching
Searching is painfully obvious: Simply read and follow the appropriate buckets,
until you get to a leaf, which is your final destination. It is a match, if the
key of the leaf...
News & Blog Posts
2017-05-16
~10 min read
pauljmiller.com
...Adding interactivity
Time to move on to the fn event() method! The event() method receives an Event called event that we can match on:
fn event(&mut self, event: &Event, _ctx: &mut EventCtx, _data: &mut String, _env: &Env) {
match event {
Event::MouseDown(mouse) => {
dbg!(mouse);
},
_ => (),
}
}
If you run the app...
News & Blog Posts
2019-10-29
~16 min read
github.com
...It is a simple method with an obvious implementation, but it provides
convenience while working with string segmentation manually, which we already
have ample tools for (for example the method `find` that returns the first
matching byte offset).
Using `split_at` can lead to less repeated bounds checks, since it...
RFC 1123
RFC
2015-05-17
~2 min read
doc.rust-lang.org
...4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
You can also run tests whose name matches a pattern:
$ cargo test test_foo
$ cargo test test_foo
Compiling blah v0.1.0 (file:///nobackup/blah)
Finished dev [unoptimized + debuginfo] target(s) in 0.35 secs
Running target/debug...
Rust by Example
Book
2024-01-01
~2 min read
www.redox-os.org
...macro_rules! t { ... }
fn main() -> Result<()> {
match unsafe { t!(libc::fork()) } {
0 => child(),
pid => Parent::new(pid).run()
}
}
fn child() -> Result<()> {
unsafe {
// Attach the parent process to debug this child process
t!(libc::ptrace(libc::PTRACE_TRACEME, 0 as libc::pid_t, NULL, NULL));
// Pause execution by raising SIGSTOP until...
News & Blog Posts
2019-06-25
~6 min read
2017.rustfest.eu
...there has never been a better time to use Rust for your next service, application, or tool!
GStreamer & Rust – A perfect match
Luis de Bethencourt
Luis de Bethencourt is a freedom-loving technocrat, who currently works for Samsung’s Open Source Group in London. He has always enjoyed programming and...
News & Blog Posts
2017-03-28
~10 min read