Rohit Sachdeva
@_r_sachdeva
#Rust Senior Engineer: #Rustlang / #AsyncRust / #SystemDesign /#Backend / Cryptography / Machine Learning https://github.com/rsachdeva/drive-deposits
คุณอาจชื่นชอบ
Carl Lerche Presentation for #Rust #Rustlang Backend Developers -- Rust: A Productive Language for Writing Database Applications: infoq.com/presentations/…
infoq.com
Rust: a Productive Language for Writing Database Applications
Carl Lerche discusses Rust's potential as a productive language for building higher-level applications like web apps and backends, traditionally seen as performance-sensitive domains. He explains how...
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…
Track #Rust releases from: releases.rs release-monitoring.org/project/7635/ github.com/rust-lang/rust… #Rustlang
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
United States เทรนด์
- 1. Cowboys 68.2K posts
 - 2. Nick Smith Jr 9,316 posts
 - 3. Cardinals 30.5K posts
 - 4. Kawhi 4,141 posts
 - 5. #WWERaw 60.8K posts
 - 6. #LakeShow 3,391 posts
 - 7. Jerry 45.4K posts
 - 8. Kyler 8,306 posts
 - 9. Blazers 7,725 posts
 - 10. Logan Paul 9,985 posts
 - 11. No Luka 3,474 posts
 - 12. Jonathan Bailey 19.6K posts
 - 13. Jacoby Brissett 5,496 posts
 - 14. Pickens 6,660 posts
 - 15. Cuomo 172K posts
 - 16. Koa Peat 6,222 posts
 - 17. Valka 4,643 posts
 - 18. Javonte 4,307 posts
 - 19. AJ Dybantsa 1,694 posts
 - 20. Bronny 15K posts
 
คุณอาจชื่นชอบ
Something went wrong.
Something went wrong.