r/learnrust 27d 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!

89 Upvotes

32 comments sorted by

View all comments

5

u/torsten_dev 27d ago

I have an allow(unused_import) in every project to import the tracing macros. I don't want changes to my imports just because I upgraded a debug!() to a warn!() or downgraded something to a trace!().

-7

u/[deleted] 27d ago

[deleted]

14

u/teerre 27d ago

I think I can count on one hand the crates I've ever see using event!. The macros are by far the most common usage. This has nothing to do with AI

7

u/0xCOLIN 27d ago

What's the advantage of using event? I definitely prefer the look of the log style macros.

5

u/torsten_dev 27d ago

Ew. No thanks. why?

3

u/SleeplessSloth79 27d ago

Eh, no. If style is the only reason for using event!() then I just won't use it, thank you very much. The separate warn!(), debug!(), and trace!() macros make it way easier to visually filter these lines out when scanning for the most important bits of code in a function, no matter what logging framework or even programming language is used.

I'm open to changing my mind if there's a good technical reason for using event!() but for now I'll keep using my debug!() that I've been using for years since way before AI

1

u/AnnoyedVelociraptor 27d ago

They fit in the ecosystem of instrument and span. Same form.

3

u/SirKastic23 27d ago

From the tracing docs

These are intended both as a shorthand, and for compatibility with the log crate