_r_sachdeva's profile picture. #Rust Senior Engineer:  #Rustlang / #AsyncRust / #SystemDesign /#Backend / Cryptography /  Machine Learning
https://github.com/rsachdeva/drive-deposits

Rohit Sachdeva

@_r_sachdeva

#Rust Senior Engineer: #Rustlang / #AsyncRust / #SystemDesign /#Backend / Cryptography / Machine Learning https://github.com/rsachdeva/drive-deposits

looks like it has been announced: tokio.rs/blog/2025-06-1…

It probably is time for TokioConf... huh.



Rohit Sachdeva 已轉發

Rust 1.85.0 has been released! 🌈🦀✨ Not only does this release add async closures, it also includes a whole new Rust Edition, Rust 2024! 🎆🚀 Check out the blog post for an overview of all the changes and additions: blog.rust-lang.org/2025/02/20/Rus…


An async function, when called, returns a Future because the Future is return type. This is just returning its return type like any regular function. The only change is Future wraps the declared return type in async function, to make the full return. #asyncrust


Rust Range Counting: (low..=high).count() vs (high-low) + 1 Both are equally fast - Range's count() uses optimized arithmetic under the hood. No iteration one by one in count. Calculates the number of steps between start and end using Step::steps_between! #Rust #Rustlang


match some_string.as_str() { "hello" => println!("Found hello"), _ => println!("Something else") } Pattern Match: doc.rust-lang.org/reference/patt… shows String literals which are of &str type, not String. You can directly use "hello" but not "hello".to_string(). #rust #rustlang


get() method: Vec vs String // Vec get signature has: I: SliceIndex<[T]> // String get signature has: I: SliceIndex<str> impl SliceIndex: Vec ([T]): single index (usize) and ranges String (str): Only ranges even for one character[s.get(0..1)] due to UTF-8 #Rust #Rustlang


The turbofish follows one consistent pattern: ::<T> where T is your type parameter. "42".parse::<i32>(); Turbofish portion: ::<i32> Vec::<Vec<u8>>::new() Turbofish portion: ::<Vec<u8>> Associated function call: ::new() Creates a vector holding byte vectors #rust #rustlang


// Instead of match result { // Ok(val) => val, // Err(_) => compute_default() // } let value = result.unwrap_or_else(|_| compute_default()); // Instead match result { // Ok(val) => val, // Err(_) => Default::default() // } let value = result.unwrap_or_default(); #Rust #Rustlang


Refutable Dictionary meaning: 'capable of being proved false'. Such patterns can hence ONLY be used in: - if let expressions - while let expressions - match arms expressions (except the last arm which must be irrefutable) - let...else statements #Rust #Rustlang


In #Rust traits: Definition: Self: Unknown type self: Future instance of unknown type Self Implementation: Self: Becomes concrete implementing type self: Becomes instance of implementing type Note: self is shorthand for self: Self #Rustlang


For From trait: What comes after `for` is the TARGET type What's in angle brackets is what we're converting FROM For Deref trait: What comes after `for` is what we're converting FROM Target type is specified in associated type (type Target = ) #Rust #Rustlang


HashMap #rustlang fn and_modify<F>(self, f: F) -> Self where F: FnOnce(&mut V) Closure's return type F: FnOnce(&mut V) returns () Function and_modify's return type -> Self Two returns different purposes:closure return is for modification, function's return enables fluent API


Less Common Uses of ? and !: ?Sized in Trait Bounds: struct Container<T: ?Sized> { data: Box<T> } // Allows both sized/unsized ! in Trait Implementations: impl !Send for MyType {} // non-thread-safe Common: ? for error handling ! for declarative macros #Rustlang


fn execute(writer_half: OwnedWriteHalf) { let mut writer = writer_half; // And Reads very naturally in the code that follows } // 〰️ // Same as fn execute(mut writer_half: OwnedWriteHalf) { } Choose by Readability. #Rust #Rustlang


&str TYPE size is always 16 bytes (fat ptr) DATA size varies by content let s = String::from("Hello"); let slice = &s[1..]; // "ello" println!("Type: {}, Data: {}", std::mem::size_of::<&str>(), std::mem::size_of_val(slice)); // 4 #Rustlang #Rust


let owned = String::from("world"); let y : Option<&str> = owned.get(1..3); let text = "hello"; let z: Option<&str> = text.get(1..3); Type annotations are just added to show slice &str. So get supports range as input. Returns slice. #Rust #Rustlang


let v = vec![1, 2, 3]; let x: Option<&i32> = v.get(1); // Single element let y: Option<&[i32]> = v.get(0..2); // Slice range Type annotations are just added to show slice &[i32]. So get supports range as input. Returns slice. #Rust #Rustlang


Loading...

Something went wrong.


Something went wrong.