Rohit Sachdeva
@_r_sachdeva
#Rust Senior Engineer: #Rustlang / #AsyncRust / #SystemDesign /#Backend / Cryptography / Machine Learning https://github.com/rsachdeva/drive-deposits
You might like
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 Trends
- 1. #UFC321 51.1K posts
- 2. Ole Miss 9,618 posts
- 3. Arbuckle 1,616 posts
- 4. Oklahoma 14.3K posts
- 5. Lane Kiffin 4,807 posts
- 6. Hugh Freeze N/A
- 7. UCLA 6,679 posts
- 8. Jackson Arnold N/A
- 9. Cunha 60.4K posts
- 10. Anthony Taylor 10.7K posts
- 11. Sunderland 113K posts
- 12. #MUFC 25.6K posts
- 13. Lamar 17.5K posts
- 14. Cam Coleman 1,128 posts
- 15. #iufb 1,870 posts
- 16. Sark 3,024 posts
- 17. #Huskers N/A
- 18. Mbeumo 40.1K posts
- 19. #Sooners 1,668 posts
- 20. Welbeck 8,842 posts
You might like
-
Michael ORourke
@morourkej -
Ray Hartjen
@RayHartjen -
DeShaun’s Marketing, Inc.
@DeShaunsMrk -
Steven Connelly
@mkmmasconnelly1 -
Simon Hossell
@simonhossell -
GKL
@gklive1 -
JMax
@jarrodmax -
Maria Sigacheva, ACCA
@mariaxsigacheva -
Michael Altiero
@MichaelAltiero -
Unique Thoughts
@SEODummy1 -
Sushill Waddhwa
@WadhwaSushil -
UDAYAN MODHE
@umodhe
Something went wrong.
Something went wrong.