r/ProgrammerHumor • • 2d ago

Meme checkBuildSettings

Post image
3.8k Upvotes

89 comments sorted by

View all comments

Show parent comment

3

u/TiF4H3- 2d ago edited 2d ago

And even better, it's entierly customizable using directives within the code itself!
It evencan be set for the whole project, or for a specific module.

If you are still prototyping, you can add a little

#![allow(unused)]

and change it into a deny/forbid on the production build.

On the other end, a

#![forbid(unsafe)]

is a wonderful guarantee for your codebase.

There also a lot of very specific lints you can turn on, relating to endianness, and a bunch of more domain-specific things.

Quick edit:

More specifically, there's the whole restriction lint group, which is allow per default.

It has a lot of things related to enforcing some uncommon coding guidelines (like no else if without an else).

And there's also the whole pedantic lint group, also allow per default.

It's instead lints that are technically good, but more among the realm of micro optimizations and pedantic bullshit than the realm of actually important errors (like using an unstable sort to sort primitives, as it's slightly faster than a stable one).
But they can be very useful in contexts where these actually matter.

3

u/PrincessRTFM 2d ago

point of detail: it's #![...] not !#[...]

also, inline code doesn't get syntax highlighting so the leading rs for the language just gets rendered directly

3

u/TiF4H3- 2d ago

Thanks!

I always mess up the #! and never remember which is correct, lol.

2

u/Kiro0613 1d ago

What's wrong with else if without an else?

1

u/TiF4H3- 1d ago

For most people, absolutely nothing.

But some coding guidelines enforces that, so there is a lint that you can toggle on, in order to enforce this guideline.

A maybe better example would be the implicit_return lint, which guards against Rust's implicit returning of the last expression of a block.
It's very much idiomatic Rust, but there could (and most likely is) a team that is still somewhat unfamiliar with Rust, and prefers to ban as much implicit things as possible.

2

u/pint_o_paint 2d ago

I hate that for a second I suspected your post to be an AI-copypasta; only because at first glance I saw proper formatting and an upbeat/enthusiastic intro ("And even better, it's entierly customizable[...]!").

I love proper formatting and enthusiastic posts, darn it.