summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/from_str_radix_10.txt
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/tools/clippy/src/docs/from_str_radix_10.txt25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/from_str_radix_10.txt b/src/tools/clippy/src/docs/from_str_radix_10.txt
new file mode 100644
index 000000000..f6f319d3e
--- /dev/null
+++ b/src/tools/clippy/src/docs/from_str_radix_10.txt
@@ -0,0 +1,25 @@
+### 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()?;
+``` \ No newline at end of file