Rohit Sachdeva
banner
rohit-sachdeva.bsky.social
Rohit Sachdeva
@rohit-sachdeva.bsky.social
#Rust Senior Engineer: #rustlang / #AsyncRust / #SystemDesign / #Backend Development / Cryptography / Machine Learning

https://github.com/rsachdeva/drive-deposits
https://github.com/rsachdeva/simple-chat

https://github.com/rsachdeva
Reposted by Rohit Sachdeva
Hello World! Announcing the inaugural TokioConf. April 20-22, 2026, in Portland, OR. tokio.rs/blog/2025-06...
Announcing TokioConf 2026 | Tokio - An asynchronous Rust runtime
Tokio is a runtime for writing reliable asynchronous applications with Rust. It provides async I/O, networking, scheduling, timers, and more.
tokio.rs
June 19, 2025 at 6:31 PM
Carl Lerche Presentation for #Rust #Rustlang Backend Developers -- Rust: A Productive Language for Writing Database Applications: www.infoq.com/presentation...
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 ...
www.infoq.com
June 13, 2025 at 5:19 AM
Reposted by Rohit Sachdeva
I suppose I should link directly to this to get a proper preview: youtu.be/thdpaw_3VTw?...
February 20, 2025 at 10:53 AM
January 26, 2025 at 7:26 PM
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 when the async function is called. #asyncrust
January 24, 2025 at 3:30 AM
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
January 21, 2025 at 10:49 PM
match some_string.as_str() {
"hello" => println!("Found hello"),
_ => println!("Something else")
}

Pattern Match:
doc.rust-lang.org/reference/pa... shows String literals which are of &str type, not String. You can directly use "hello" but not "hello".to_string().

#rust #rustlang
Patterns - The Rust Reference
doc.rust-lang.org
January 10, 2025 at 10:21 PM
get() method: Vec vs String
// Vec get signature has:
where I: SliceIndex<[T]>
// String get signature has:
where I: SliceIndex
SliceIndex implementations:
Vec ([T]): Both single index (usize) and ranges
String (str): Only ranges even for one character[s.get(0..1)] due to UTF-8

#Rust
#Rustlang
January 3, 2025 at 5:20 PM
The turbofish follows one consistent pattern: :: where T is your type parameter.

"42".parse::();
Turbofish portion: ::

Vec::>::new()
Here we see:
Turbofish portion: ::>
Associated function call: ::new()
Creates a vector holding byte vectors

#rust #rustlang
December 29, 2024 at 8:08 PM
// Instead of match result {
// Ok(val) => val,
// Err(_) => compute_default()
// }
let value = result.unwrap_or_else(|_| compute_default());
// Instead of match result {
// Ok(val) => val,
// Err(_) => Default::default()
// }
let value = result.unwrap_or_default();

#Rust #Rustlang
December 26, 2024 at 10:38 PM
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
December 22, 2024 at 10:13 PM
The common point between Rust's standard library (std) and Tokio is the Future trait (doc.rust-lang.org/std/future/t...) .

#rust #rustlang #asyncrust #tokio_rs
December 12, 2024 at 3:29 AM
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
December 10, 2024 at 5:39 PM
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
December 9, 2024 at 11:21 PM
An async block directly creates a Future
An async function, when called, returns a Future.
Note `when called` in async function...

#Rust #Async #Rustlang #AsyncRust
December 8, 2024 at 5:40 PM
HashMap #rustlang
fn and_modify(self, f: F) -> Self where F: FnOnce(&mut V)

1. Closure's return type F: FnOnce(&mut V) returns ()
2. Function and_modify's return type -> Self
Two returns serve different purposes- closure return is for modification, function's return enables fluent API chaining
December 7, 2024 at 12:16 AM
Less Common Uses of ? and !:

?Sized in Trait Bounds:

struct Container {
data: Box
} // Allows both sized/unsized

! in Trait Implementations:
impl !Send for MyType {} // Explicitly non-thread-safe

More common uses: ? for error handling ! for declarative macros

#Rust #RustLang
December 6, 2024 at 9:45 PM
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) {

}

In both you get Direct link to parameter name passed

Choose by Readability. #Rust #Rustlang
December 6, 2024 at 6:11 PM
The word `await` perfectly captures async essence: actively anticipating results while staying productive!
await = waiting in anticipation
wait = passive waiting
That's why #AsyncRust (and some other languages) chose await - it's all about productive anticipation! #RustLang
December 6, 2024 at 5:24 PM
get supports range as input. Returns slice:

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.
#Rust #Rustlang
December 5, 2024 at 10:27 PM
&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
December 5, 2024 at 6:35 PM
In select!:Multiple branches compete/race like diverging paths;Only one branch "wins" and gets executed

In join!: Different branches merge back together; Like tributaries joining into a main river; All branches must complete to form the whole

#AsyncRust #Rustlang #tokio_rs
December 5, 2024 at 5:20 PM