beachape.com
...SavedUser = labelled_convert_from(n_user);
but the following fails at compile-time because the fields are mis-matched (first_name and last_name have been swapped):
1
2
3
4
5
6
7
8
9
10
11
// Uh-oh! Fields are jumbled :(
#[derive(LabelledGeneric)]
struct JumbledUser<'a> {
last_name...
News & Blog Posts
2017-03-07
~9 min read
rust-lang.github.io
...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
...The soname is resolved at compile time by scanning the compiler's library path and matching the optional crate_name provided against the crate_name attributes that were declared on the external crate when it was compiled. If no crate_name is provided, a default name attribute is assumed, equal...
The Rust Reference
Book
2024-01-01
~2 min read
nitschinger.at
...1
2
3
4
5
6
7
8
9
10
println!("Cpu Binding before explicit bind: {:?}", topo.get_cpubind(CPUBIND_PROCESS));
println!("Cpu Location before explicit bind: {:?}", topo.get_cpu_location(CPUBIND_PROCESS));
match topo.set_cpubind(cpuset, CPUBIND_PROCESS) {
Ok(_) => println!("Correctly bound to last core"),
Err(e) => println...
News & Blog Posts
2016-02-15
~12 min read
fasterthanli.me
...Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
println!("MyFuture::poll()");
match self.slept {
false => {
// make sure we're polled again in one second
let waker = cx.waker().clone();
std::thread::spawn(move || {
std::thread::sleep(Duration::from_secs(1));
waker.wake();
});
self.slept = true;
Poll::Pending
}
true => Poll...
Rust Walkthroughs
2021-03-31
~42 min read
www.ralfj.de
...Whenever a mutable reference is created, a matching Uniq is pushed onto the stack for every location “covered by” the reference – i.e., the locations that would be accessed when the reference is used (starting at where it points to, and going on for size_of_val many bytes).
Whenever...
News & Blog Posts
2018-08-07
~25 min read
rust-lang.github.io
...The lint trivial_constraints would be added, matching the pre-1.7 semantics of E0193, and would be set to warn by default.
How We Teach This
This feature does not need to be taught explicitly. Knowing the basic rules of where clauses, one would naturally already expect this to...
RFC 2056
RFC
2017-07-05
~2 min read
www.meilisearch.com
...A search for 2024 will match only 2024, not 2025 or 2004. This is especially helpful when searching for postal addresses or phone numbers.
Skipping number fuzziness can also speed up your indexing, especially for datasets that contain many unique numbers.
New: Lexicographic string filters
You can now compare any...
Project/Tooling Updates
2025-06-11
~2 min read
blog.servo.org
...Manishearth updated rust-url to match new specification changes.
frewsxcv made placeholders appear in text areas.
SimonSapin replaced some uses of strings for CSS property names with enums.
UK992 fixed some issues with the Windows installer.
mmatyas made a number of improvements to allow Android to build again.
gw & frewsxcv...
Other Weeklies from Rust Community
2016-12-20
~2 min read
developerlife.com
...fn main() {
println!("Welcome to rtelnet");
let cli_arg = CLIArg::parse();
let address = cli_arg.address;
let port = cli_arg.port;
let socket_address = format!("{}:{}", address, port);
if !cli_arg.log_disable {
femme::start()
}
match match cli_arg.subcommand {
CLISubcommand::Server => start_server(socket_address),
CLISubcommand::Client => start_client(socket...
Rust Walkthroughs
2024-02-07
~13 min read
agmprojects.com
...DateTime<Utc>,
}
An important thing to note, the fields here in the struct need to match the order they are defined in the schema.rs file. This will also match the order they were defined in the migration file. So if you were to remove body and add it back...
Rust Walkthroughs
2021-05-12
~43 min read
0xc45.com
...f32 = 0.2;
let period = note.envelope.clock / audio_ctx.sample_rate;
// determine next sample value
let sample = match note.waveform {
Waveform::SINE => (note.frequency * TAU * period).sin(),
Waveform::SQUARE => match (note.frequency * TAU * period).sin() {
i if i > 0_f32 => 1_f32,
_ => -1_f32,
},
Waveform::TRIANGLE => (note.frequency * TAU...
Observations/Thoughts
2022-01-19
~6 min read
www.heise.de
...u64 = 1024;
let response_content_length = match response.body().size_hint().upper() {
Some(v) => v,
None => MAX_ALLOWED_RESPONSE_SIZE + 1 // Just to protect ourselves from a malicious response
};
if response_content_length < MAX_ALLOWED_RESPONSE_SIZE {
let body_bytes = hyper::body::to_bytes(response.into_body()).await?;
println!("body...
Miscellaneous
2023-01-18
~2 min read
osblog.stephenmarz.com
...8 => {
// Environment (system) call from User mode
println!("E-call from User mode! CPU#{} -> 0x{:08x}", hart, epc);
return_pc = do_syscall(return_pc, frame);
},
Most operating systems build a table with function pointers, but I'm using Rust's match statement here. I haven't done any performance calculations...
News & Blog Posts
2020-07-08
~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
rust-lang.github.io
...SomeTrait does not implement SomeTrait" - no indication that the non-object-safe method were to blame, only a failure in trait matching.
Another advantage of this proposal is that it implies that all method-calls can always be rewritten into an equivalent UFCS call. This simplifies the "core language" and...
RFC 255
RFC
2014-09-22
~6 min read
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
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
blog.servo.org
...Applicants form pairs
(“teams”) and apply to be matched with a mentoring open source project - if a team is selected for a project, they will
contribute to that project for those three months while receiving a stipend and regular coaching in return.
How is this program different from similar Summer...
Call for Participation
2017-02-28
~2 min read
guillaumegomez.github.io
...Recent doc contributions
@estebank provided context for missing comma in match arm and if statement without block.
@vi added foldable impl blocks in rustdoc.
@QuietMisdreavus added readme for librustdoc.
@remexre fixed docs for ASCII functions to no longer claim U+0021 is ‘@’.
@mark-i-m splitted E0404 to E0909; get...
News & Blog Posts
2018-03-06
~2 min read