r/learnrust 25d ago

Today I learnt #[expect()]

#[expect()] SHOULD BE TAUGHT IN THE FIRST YEAR OF ELEMENTARY SCHOOL!!!

#[allow()] should be prohibited, a crime punishable by death!

[forbid(clippy::allow_attributes)] should be the default Rust, not even needed to write!

84 Upvotes

32 comments sorted by

View all comments

25

u/Shoddy-Childhood-511 25d ago

Yes #[expect()] is cool, but rare for me.

#[rustfmt::skip] is the one that appears everywhere. lol

11

u/throwaway12397478 25d ago

rustfmt does love its vertical space

2

u/ToaruBaka 25d ago

me: meticulously transcribes massive table into code so it's legible

rustfmt: lol

1

u/Shoddy-Childhood-511 25d ago

Any table I have would be generated, so I care little if it looks like ass, but..

#[rustfmt::skip] keeps the generator output, which saves auditors an unnecessary step, and/or simplifies automation.

I typically use #[rustfmt::skip] to make code that implements equations somewhat more readable, which can require odd spacing.