diff options
author | Haibo Huang <hhb@google.com> | 2020-10-29 19:19:23 -0700 |
---|---|---|
committer | Haibo Huang <hhb@google.com> | 2020-10-29 19:19:23 -0700 |
commit | fa1e128f8d76fc7692bba478999d4b70b0b566ad (patch) | |
tree | cc76fcd4bb0aa6f23ddd864e255ab5d995b4e572 /src/lib.rs | |
parent | acc09beccc655abcc141a28ad448b8b8a0544f26 (diff) | |
download | num-traits-fa1e128f8d76fc7692bba478999d4b70b0b566ad.tar.gz |
Upgrade rust/crates/num-traits to 0.2.14
Test: make
Change-Id: I65d209f9bebc2dcbb3d3ad95390afd6dae2f17b7
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -67,7 +67,7 @@ pub mod sign; pub trait Num: PartialEq + Zero + One + NumOps { type FromStrRadixErr; - /// Convert from a string and radix <= 36. + /// Convert from a string and radix (typically `2..=36`). /// /// # Examples /// @@ -80,6 +80,18 @@ pub trait Num: PartialEq + Zero + One + NumOps { /// let result = <i32 as Num>::from_str_radix("foo", 10); /// assert!(result.is_err()); /// ``` + /// + /// # Supported radices + /// + /// The exact range of supported radices is at the discretion of each type implementation. For + /// primitive integers, this is implemented by the inherent `from_str_radix` methods in the + /// standard library, which **panic** if the radix is not in the range from 2 to 36. The + /// implementation in this crate for primitive floats is similar. + /// + /// For third-party types, it is suggested that implementations should follow suit and at least + /// accept `2..=36` without panicking, but an `Err` may be returned for any unsupported radix. + /// It's possible that a type might not even support the common radix 10, nor any, if string + /// parsing doesn't make sense for that type. fn from_str_radix(str: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>; } |