Skip to content

Commit e86e6b4

Browse files
authoredOct 15, 2023
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.
2 parents b0fedc0 + e15e9a6 commit e86e6b4

File tree

1 file changed

+5
-6
lines changed
  • library/core/src/convert

1 file changed

+5
-6
lines changed
 

‎library/core/src/convert/mod.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -618,12 +618,11 @@ pub trait TryInto<T>: Sized {
618618
/// For example, there is no way to convert an [`i64`] into an [`i32`]
619619
/// using the [`From`] trait, because an [`i64`] may contain a value
620620
/// that an [`i32`] cannot represent and so the conversion would lose data.
621-
/// This might be handled by truncating the [`i64`] to an [`i32`] (essentially
622-
/// giving the [`i64`]'s value modulo [`i32::MAX`]) or by simply returning
623-
/// [`i32::MAX`], or by some other method. The [`From`] trait is intended
624-
/// for perfect conversions, so the `TryFrom` trait informs the
625-
/// programmer when a type conversion could go bad and lets them
626-
/// decide how to handle it.
621+
/// This might be handled by truncating the [`i64`] to an [`i32`] or by
622+
/// simply returning [`i32::MAX`], or by some other method. The [`From`]
623+
/// trait is intended for perfect conversions, so the `TryFrom` trait
624+
/// informs the programmer when a type conversion could go bad and lets
625+
/// them decide how to handle it.
627626
///
628627
/// # Generic Implementations
629628
///

0 commit comments

Comments
 (0)
Please sign in to comment.