Skip to content

Instantly share code, notes, and snippets.

View MolotovCherry's full-sized avatar
😄
Life is beautiful

Cherry MolotovCherry

😄
Life is beautiful
  • At my computer
View GitHub Profile
@MolotovCherry
MolotovCherry / closures.md
Last active June 16, 2026 16:29
Rust Closures

Closures Decompiled

Closures get compiled down to anonymous structs which include their captures as the struct's fields.

That means a capturing closure

let x = 1i32;
let c = || println!("{x}");
c();

Is compiled to[^1]

@MolotovCherry
MolotovCherry / Cargo.toml
Last active March 1, 2022 14:01
Rust WinAPI (windows-rs) process Privilege granter
[dependencies]
thiserror = "1.0.30"
[dependencies.windows]
version = "0.33.0"
features = [
"Win32_System_Threading",
"Win32_Foundation",
"Win32_Security",
"Win32_System_SystemServices"