Rollup merge of #116594 - tae-soo-kim:convert-tryfrom-doc, r=scottmcm
Fix `std::convert::TryFrom` doc Original text: > truncating the [i64](https://doc.rust-lang.org/std/primitive.i64.html) to an [i32](https://doc.rust-lang.org/std/primitive.i32.html) (essentially giving the [i64](https://doc.rust-lang.org/std/primitive.i64.html)’s value modulo [i32::MAX](https://doc.rust-lang.org/std/primitive.i32.html#associatedconstant.MAX)) This can't be true, because `i32::MAX` is an odd number. The correct value seems `(i32::MAX + 1) * 2`, but this is complicated and distracting, and I suggest removing the parentheses entirely.
This commit is contained in:
commit
e86e6b45e7
@ -618,12 +618,11 @@ pub trait TryInto<T>: Sized {
|
|||||||
/// For example, there is no way to convert an [`i64`] into an [`i32`]
|
/// For example, there is no way to convert an [`i64`] into an [`i32`]
|
||||||
/// using the [`From`] trait, because an [`i64`] may contain a value
|
/// using the [`From`] trait, because an [`i64`] may contain a value
|
||||||
/// that an [`i32`] cannot represent and so the conversion would lose data.
|
/// that an [`i32`] cannot represent and so the conversion would lose data.
|
||||||
/// This might be handled by truncating the [`i64`] to an [`i32`] (essentially
|
/// This might be handled by truncating the [`i64`] to an [`i32`] or by
|
||||||
/// giving the [`i64`]'s value modulo [`i32::MAX`]) or by simply returning
|
/// simply returning [`i32::MAX`], or by some other method. The [`From`]
|
||||||
/// [`i32::MAX`], or by some other method. The [`From`] trait is intended
|
/// trait is intended for perfect conversions, so the `TryFrom` trait
|
||||||
/// for perfect conversions, so the `TryFrom` trait informs the
|
/// informs the programmer when a type conversion could go bad and lets
|
||||||
/// programmer when a type conversion could go bad and lets them
|
/// them decide how to handle it.
|
||||||
/// decide how to handle it.
|
|
||||||
///
|
///
|
||||||
/// # Generic Implementations
|
/// # Generic Implementations
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user