Post #2016404
2026-04-20 11:12 UTC
Replies (1)
-
@bshn@hachyderm.io 2026-04-20 11:20
First one is kinda small and simple **Trivial_Casts** 🔢➡️🔟 > The trivial_casts lint in Rust is designed to catch what the Rust compiler considers to be "obviously unnecessary" type casts. These casts are often a result of typos or misunderstandings of how types work in Rust, and they can lead to unexpected behavior if not caught early on. When you cast one type to another, the compiler will automatically perform certain "trivial" casts that are considered safe and obvious. However, it might also flag cases where the cast is unnecessary because Rust can infer the correct type without any issues. These flagged cases are what the trivial_casts lint is designed to catch. Example: ```rust let square = Square([2; 8]); let square = &square as □ ``` #lotw