hermanradtke.com
...loop {
match self.sock.try_read_buf(&mut recv_buf) {
// the socket receive buffer is empty, so let's move on
// try_read_buf internally handles WouldBLock here too
Ok(None) => {
debug!("CONN : we read 0 bytes");
break;
},
Ok(Some(n)) => {
debug!("CONN : we read {} bytes", n);
// if we read...
From the Blogosphere
2015-07-27
~7 min read
mainmatter.com
...PdfWriterConfiguration) -> Result<Term, RustlerError> {
match priv_create_pdf(config) {
Ok(()) => Ok(atoms::ok().to_term(env)),
Err(ref error) => return Err(RustlerError::Term(Box::new(io_error_to_term(error)))),
}
}
fn priv_create_pdf(config: PdfWriterConfiguration) -> Result<(), std::io::Error> {}create_pdf is slightly more complicated as it involves some...
Rust Walkthroughs
2023-02-08
~8 min read
rust-lang.github.io
...Attribute invocations can only match the attr rules, and non-attribute invocations can only match the non-attr rules. This allows adding attr rules to an existing macro without breaking backwards compatibility.
An attribute macro may emit code containing another attribute, including one provided by an attribute macro. An attribute...
RFC 3697
RFC
2024-09-20
~7 min read
blog.servo.org
...mattnenterprise updated some older Fetch code to match changes to the specification.
beholdnec fixed a shader problem that was breaking Servo on some AMD drivers.
karenher added support for tracking line numbers in the HTML parser.
canaltinova corrected the serialization of overflow properties in CSS.
hiikezoe made animated colors use...
Other Weeklies from Rust Community
2017-01-10
~2 min read
rtoch.com
...LinkedList<Vec<Operation>> = LinkedList::new();
stack.push_back(Vec::new());
for token in tokens {
let cur_operations = stack.back_mut().expect("Stack should not be empty!");
match token {
Token::MoveRight => {
if let Some(Operation::MoveRight(x)) = cur_operations.last_mut() {
*x += 1;
} else {
cur_operations.push(Operation::MoveRight(1))
}
}
Token...
Miscellaneous
2022-03-23
~7 min read
jackh726.github.io
...fn transmute_lifetime<'a, 'b, T>(t: &'a (T,)) -> &'b T {
match (&t,) {
((u,),) => u,
}
}
fn main() {
let y = Box::new((42,));
let x = transmute_lifetime(&y);
}
Stable emits the following error:
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
--> src/main.rs:2:11
|
2 | match...
Observations/Thoughts
2022-06-15
~13 min read
smista.ai
...MemoryArgs) -> Result<String, Self::Error> {
let MemoryArgs {
op,
scope,
key,
value,
} = args;
match op {
MemoryOp::Record => {
let value = value.ok_or(MemoryToolError::MissingValue)?;
match scope {
MemoryScope::User => {
self.storage
.put_user_memory(Some(key.clone()), value)
.await?;
}
MemoryScope::Session => {
self.storage
.put_session_memory(Some(key.clone()), value)
.await?;
}
}
Ok...
Rust Walkthroughs
2026-06-17
~7 min read
rust-analyzer.github.io
...during code analysis.
#3722 fix parsing lambdas with return type.
#3724 blame the right queries for memory usage.
#3725 fix TypeScript memory leak on server restart.
#3745 Merge Imports assist correctly handles *.
#3764 fix index out of bounds error during workspace loading.
#3761 Fill Match Arms assist correctly preserves comments.
News & Blog Posts
2020-03-31
~1 min read
rust-analyzer.github.io
#10979 don’t show trait flyimports for impl trait and placeholders.
#10976 show case-insensitive exact matches instead of fuzzy flyimport for short paths.
#10986 fix lint completions not working for unclosed attributes.
#10960 fix handling of macros in extern blocks.
#10957 fix some TryToNav impls not upmapping ranges out...
Project/Tooling Updates
2021-12-15
~1 min read
rust-lang.github.io
...cannot move out of borrowed content
--> /Users/jturner/Source/errors/borrowck-move-out-of-vec-tail.rs:30:17
I’m trying to track the ownership of the contents of `tail`, which is borrowed, through this match
statement:
29 | match tail {
In this match, you use an expression of the...
RFC 1644
RFC
2016-06-07
~13 min read
integer32.com
...usize) -> Result<&str> {
let s = &s[location..];
match s.find("\n") {
Some(pos) => {
let head = &s[..pos];
Ok((head, location + pos + "\n".len()))
},
None => {
Err(location)
}
}
}
fn main() {
let input = "hello\nworld";
assert_eq!(Ok(("hello", 6)), parse_until_newline(input, 0));
assert_eq!(Err(6), parse_until_newline(input...
News & Blog Posts
2017-02-07
~5 min read
rust.code-maven.com
...let database_folder = match std::env::var("DATABASE_PATH") {
Ok(val) => std::path::PathBuf::from(val),
Err(_) => {
let current_dir = std::env::current_dir().unwrap();
current_dir.join("db")
}
};
Connect to the database on the filesystem
Then we connect to the database folder via the RocksDb driver.
let db = Surreal...
Miscellaneous
2024-01-17
~5 min read
rust-analyzer.github.io
...14004 don’t escape non-snippets in Move const to impl.
#14011 fix Unwrap block for let statements.
#14037 handle boolean scrutinees better in Match to if-let assist.
#14039 make Add missing impl members work for impls inside blocks.
#14038 don’t fail workspace loading if sysroot can’t...
Project/Tooling Updates
2023-02-01
~1 min read
info.varnish-software.com
...Let's have a look at that match statement again. I told you it had some nice features, but didn't go too deep about them. One very cool aspect is destructuring, that we'll use. Match is able to give you direct access to element of a struct or...
News & Blog Posts
2016-04-11
~11 min read
blog.kolo.app
...It only has support for a limited number of types, which don't match Python's data types amazingly well.
Maybe it was time to try a different format. In particular, msgpack was looking attractive:
It is a binary format which optimises for size.
It supports many of the basic...
Rust Walkthroughs
2023-10-11
~8 min read
briankung.dev
...As mentioned before, not_whitespace will match any character that isn’t whitespace, whereas space1 will match a single space and space0 will match zero or one space.
But a few of these are custom parsers that I wrote from nom’s more basic building blocks: pinyin, jyutping, and definitions...
Rust Walkthroughs
2021-12-22
~11 min read
doc.rust-lang.org
...algebraic data types, pattern matching, type inference, semicolon statement separation
• C++: references, RAII, smart pointers, move semantics, monomorphization, memory model
• ML Kit, Cyclone: region based memory management
• Haskell (GHC): typeclasses, type families
• Newsqueak, Alef, Limbo: channels, concurrency
• Erlang: message passing, thread failure, ,
• Swift: optional bindings
• Scheme: hygienic macros
• C#: attributes...
The Rust Reference
Book
2024-01-01
~1 min read
rocket.rs
...Routes without query parameters now match requests with or without query parameters. Default rankings prefer static paths and routes with query string matches. A native Accept header structure was added. The Accept request header can be retrieved via Request::accept(). All active routes can be retrieved via Rocket::routes(). Response...
News & Blog Posts
2017-07-18
~7 min read
siciarz.net
...extern crate postgres;
use postgres::{Connection, SslMode};
fn main() {
let dsn = "postgresql://rust:rust@localhost/rust";
let conn = match Connection::connect(dsn, &SslMode::None) {
Ok(conn) => conn,
Err(e) => {
println!("Connection error: {}", e);
return;
}
};
}
The Connection type has a few methods related to making queries; perhaps the simplest one is...
24 Days of Rust continues!
2014-12-15
~3 min read
redox-os.org
...Redox was not matching POSIX behavior for file descriptors; when dup is called, the new fd should still refer to the same “file description”, which Redox did not have a concept of. I modified the kernel to match POSIX behavior.
I changed Redox’s target triple (for the gcc toolchain...
News & Blog Posts
2017-08-22
~4 min read