Skip to content

Commit b4700c5

Browse files
Rollup merge of rust-lang#147605 - Zalathar:from-str-radix, r=Mark-Simulacrum
Add doc links between `{integer}::from_str_radix` and `from_str` When parsing base-10 numbers, it's easy to miss `<Self as FromStr>::from_str` and `str::parse` as potential alternatives to `from_str_radix`. - A similar suggestion is given by https://rust-lang.github.io/rust-clippy/master/index.html#from_str_radix_10
2 parents 4bc2485 + 2be88e3 commit b4700c5

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

library/core/src/num/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,6 +1422,10 @@ macro_rules! from_str_int_impl {
14221422
/// whitespace) represent an error. Underscores (which are accepted in Rust literals)
14231423
/// also represent an error.
14241424
///
1425+
/// # See also
1426+
/// For parsing numbers in other bases, such as binary or hexadecimal,
1427+
/// see [`from_str_radix`][Self::from_str_radix].
1428+
///
14251429
/// # Examples
14261430
///
14271431
/// ```
@@ -1467,6 +1471,14 @@ macro_rules! from_str_int_impl {
14671471
///
14681472
/// This function panics if `radix` is not in the range from 2 to 36.
14691473
///
1474+
/// # See also
1475+
/// If the string to be parsed is in base 10 (decimal),
1476+
/// [`from_str`] or [`str::parse`] can also be used.
1477+
///
1478+
// FIXME(#122566): These HTML links work around a rustdoc-json test failure.
1479+
/// [`from_str`]: #method.from_str
1480+
/// [`str::parse`]: primitive.str.html#method.parse
1481+
///
14701482
/// # Examples
14711483
///
14721484
/// ```

0 commit comments

Comments
 (0)