Skip to content

Commit deedb93

Browse files
bors[bot]cuviper
andauthored
Merge #193
193: Release 0.2.13 r=cuviper a=cuviper Co-authored-by: Josh Stone <[email protected]>
2 parents f0a980b + 5e3352c commit deedb93

File tree

4 files changed

+38
-5
lines changed

4 files changed

+38
-5
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ categories = ["algorithms", "science", "no-std"]
88
license = "MIT/Apache-2.0"
99
repository = "https://github.com/rust-num/num-traits"
1010
name = "num-traits"
11-
version = "0.2.12"
11+
version = "0.2.13"
1212
readme = "README.md"
1313
build = "build.rs"
1414
exclude = ["/bors.toml", "/ci/*", "/.github/*"]

RELEASES.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
# Release 0.2.13 (2020-10-29)
2+
3+
- [The new `OverflowingAdd`, `OverflowingSub`, and `OverflowingMul` traits][180]
4+
return a tuple with the operation result and a `bool` indicating overflow.
5+
- [The "i128" feature now overrides compiler probes for that support][185].
6+
This may fix scenarios where `autocfg` probing doesn't work properly.
7+
- [Casts from large `f64` values to `f32` now saturate to infinity][186]. They
8+
previously returned `None` because that was once thought to be undefined
9+
behavior, but [rust#15536] resolved that such casts are fine.
10+
- [`Num::from_str_radix` documents requirements for radix support][192], which
11+
are now more relaxed than previously implied. It is suggested to accept at
12+
least `2..=36` without panicking, but `Err` may be returned otherwise.
13+
14+
**Contributors**: @cuviper, @Enet4, @KaczuH, @martin-t, @newpavlov
15+
16+
[180]: https://github.com/rust-num/num-traits/pull/180
17+
[185]: https://github.com/rust-num/num-traits/pull/185
18+
[186]: https://github.com/rust-num/num-traits/pull/186
19+
[192]: https://github.com/rust-num/num-traits/issues/192
20+
[rust#15536]: https://github.com/rust-lang/rust/issues/15536
21+
122
# Release 0.2.12 (2020-06-11)
223

324
- [The new `WrappingNeg` trait][153] will wrap the result if it exceeds the

src/lib.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pub mod sign;
6767
pub trait Num: PartialEq + Zero + One + NumOps {
6868
type FromStrRadixErr;
6969

70-
/// Convert from a string and radix <= 36.
70+
/// Convert from a string and radix (typically `2..=36`).
7171
///
7272
/// # Examples
7373
///
@@ -80,6 +80,18 @@ pub trait Num: PartialEq + Zero + One + NumOps {
8080
/// let result = <i32 as Num>::from_str_radix("foo", 10);
8181
/// assert!(result.is_err());
8282
/// ```
83+
///
84+
/// # Supported radices
85+
///
86+
/// The exact range of supported radices is at the discretion of each type implementation. For
87+
/// primitive integers, this is implemented by the inherent `from_str_radix` methods in the
88+
/// standard library, which **panic** if the radix is not in the range from 2 to 36. The
89+
/// implementation in this crate for primitive floats is similar.
90+
///
91+
/// For third-party types, it is suggested that implementations should follow suit and at least
92+
/// accept `2..=36` without panicking, but an `Err` may be returned for any unsupported radix.
93+
/// It's possible that a type might not even support the common radix 10, nor any, if string
94+
/// parsing doesn't make sense for that type.
8395
fn from_str_radix(str: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>;
8496
}
8597

src/ops/overflowing.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ macro_rules! overflowing_impl {
1717

1818
/// Performs addition with a flag for overflow.
1919
pub trait OverflowingAdd: Sized + Add<Self, Output = Self> {
20-
/// Returns a tuple of the addition along with a boolean indicating whether an arithmetic overflow would occur.
20+
/// Returns a tuple of the sum along with a boolean indicating whether an arithmetic overflow would occur.
2121
/// If an overflow would have occurred then the wrapped value is returned.
2222
fn overflowing_add(&self, v: &Self) -> (Self, bool);
2323
}
@@ -40,7 +40,7 @@ overflowing_impl!(OverflowingAdd, overflowing_add, i128);
4040

4141
/// Performs substraction with a flag for overflow.
4242
pub trait OverflowingSub: Sized + Sub<Self, Output = Self> {
43-
/// Returns a tuple of the subtraction along with a boolean indicating whether an arithmetic overflow would occur.
43+
/// Returns a tuple of the difference along with a boolean indicating whether an arithmetic overflow would occur.
4444
/// If an overflow would have occurred then the wrapped value is returned.
4545
fn overflowing_sub(&self, v: &Self) -> (Self, bool);
4646
}
@@ -63,7 +63,7 @@ overflowing_impl!(OverflowingSub, overflowing_sub, i128);
6363

6464
/// Performs multiplication with a flag for overflow.
6565
pub trait OverflowingMul: Sized + Mul<Self, Output = Self> {
66-
/// Returns a tuple of the subtraction along with a boolean indicating whether an arithmetic overflow would occur.
66+
/// Returns a tuple of the product along with a boolean indicating whether an arithmetic overflow would occur.
6767
/// If an overflow would have occurred then the wrapped value is returned.
6868
fn overflowing_mul(&self, v: &Self) -> (Self, bool);
6969
}

0 commit comments

Comments
 (0)