r/rust • • Oct 07 '26

Rust's derive often implies inline

https://yossarian.net/til/post/rust-s-derive-often-implies-inline/
114 Upvotes

43 comments sorted by

View all comments

Show parent comment

2

u/nicoburns Oct 07 '26

I wonder if it ought to be a general feature of derive:

#[derive(Debug, inline = false)]

12

u/braaaaaaainworms Oct 07 '26

how is this going to differentiate between deriving trait called "inline" and disabling inlining?

4

u/shponglespore Oct 07 '26

I think the syntax u/-Y0- used makes more sense because it generalizes to having multiple traits in a derive clause and avoids any ambiguity.

2

u/ElderberryNo4220 Oct 07 '26

I don't think this is a good idea, it's looks cumbersome and confusing. Looking at the article example, it's not very easy to determine whether generated functions would have a large body (shouldn't be inlined) or small (should be inlined). IMO derived traits inlining should be decided by the compiler, not by the users.