Inline In Rust
There's a lot of tribal knowledge surrounding #[inline] attribute in Rust. I often find myself teaching how it works, so I finally decided to write this down.
There’s a lot of tribal knowledge surrounding #[inline] attribute in Rust. I often find myself teaching how it works, so I finally decided to write this down. Caveat Emptor: this is what I know, not necessarily what is true. Additionally, exact semantics of #[inline] is not set in stone and may change in future Rust versions. Why Inlining Matters? Inlining is an optimizing transformation which replaces a call to a function with its body. To give a trivial example, during compilation the compiler can transform this code: fn f (w: u32 ) -> u32 { inline_me (w, 2 ) } fn inline_me (x: u32 , y: u32
related reading
- A half-hour to learn Rustfasterthanli.me
- How to use storytelling to fit inline assembly into Rustralfj.de
- Rust Optimization.md · GitHubgist.github.com
- References and Borrowing - The Rust Programming Languagedoc.rust-lang.org
- Fast and Simple Rust Internermatklad.github.io
- A Gentle Introduction to LLVM IR · mcyoungmcyoung.xyz
- Patterns for Defensive Programming in Rust | corrode Rust Consultingcorrode.dev
- Validating References with Lifetimes - The Rust Programming Languagedoc.rust-lang.org
- Methods - The Rust Programming Languagedoc.rust-lang.org
- Variables and Mutability - The Rust Programming Languagedoc.rust-lang.org
- Macros - The Rust Programming Languageweb.mit.edu
- Rust Language Cheat Sheetcheats.rs