Get the latest tech news

Rust's derive often implies inline


In Rust, one of the most common ways to implement core traits (like Debug, Display, and Clone) is to #[derive(...)] them, e.g.: #[derive(Debug)] struct Widgets { foo: u32, bar: usize, } What I didn't know until recently is that Rust currently emits #[inline] as part of these derivations. This is seemingly not guaranteed, but is implied by example in the reference and can also be seen if one expands the macros.

None

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Rust

Rust

Photo of derive

derive

Photo of inline

inline

Related news:

News photo

Tapo (Rust/Python library) now speaks TP-Link's TPAP protocol

News photo

Two ARM64-specific compiler optimization bugs, in GCC 15/16 and Rust, hit curl

News photo

Mold Linker Version 3.0.0 Release – Rewritten in Rust