RS.CLIPPY.FROM_STR_RADIX_10
From_str_radix with radix 10
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: from_str_radix_10. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Checks for function invocations of the form primitive::from_str_radix(s, 10)
Why is this bad?
This specific common use case can be rewritten as s.parse::<primitive>()
(and in most cases, the turbofish can be removed), which reduces code length
and complexity.
Known problems
This lint may suggest using (&<expression>).parse() instead of <expression>.parse()
directly in some cases, which is correct but adds unnecessary complexity to the code.
Example
let input: &str = get_input();
let num = u16::from_str_radix(input, 10)?;
Use instead:
let input: &str = get_input();
let num: u16 = input.parse()?;