RS.CLIPPY.CHECKED_CONVERSIONS

`try_from` could replace manual bounds checking when casting

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: checked_conversions. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Checks for explicit bounds checking when casting.

Why is this bad?

Reduces the readability of statements & is error prone.

Example

foo <= i32::MAX as u32;

Use instead:

i32::try_from(foo).is_ok();

Configuration

  • msrv: The minimum rust version that the project supports. Defaults to the rust-version field in Cargo.toml

    (default: current version)