about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-10-15 11:37:23 +0200
committerGitHub <noreply@github.com>2023-10-15 11:37:23 +0200
commite86e6b45e70cc30a9d1166ebc8ba7da05b9439d4 (patch)
treef141649b220b479e07af263808333dbac91c314f
parentb0fedc07ce52a7647272a34fadbf4c5585a79c0b (diff)
parente15e9a673e6770ae35d2d738aaaff304db9e5616 (diff)
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.
-rw-r--r--library/core/src/convert/mod.rs11
1 files changed, 5 insertions, 6 deletions
diff --git a/library/core/src/convert/mod.rs b/library/core/src/convert/mod.rs
index fc8d19d1a58..9407c1609c2 100644
--- a/library/core/src/convert/mod.rs
+++ b/library/core/src/convert/mod.rs
@@ -618,12 +618,11 @@ pub trait TryInto<T>: Sized {
 /// For example, there is no way to convert an [`i64`] into an [`i32`]
 /// using the [`From`] trait, because an [`i64`] may contain a value
 /// that an [`i32`] cannot represent and so the conversion would lose data.
-/// This might be handled by truncating the [`i64`] to an [`i32`] (essentially
-/// giving the [`i64`]'s value modulo [`i32::MAX`]) or by simply returning
-/// [`i32::MAX`], or by some other method.  The [`From`] trait is intended
-/// for perfect conversions, so the `TryFrom` trait informs the
-/// programmer when a type conversion could go bad and lets them
-/// decide how to handle it.
+/// This might be handled by truncating the [`i64`] to an [`i32`] or by
+/// simply returning [`i32::MAX`], or by some other method.  The [`From`]
+/// trait is intended for perfect conversions, so the `TryFrom` trait
+/// informs the programmer when a type conversion could go bad and lets
+/// them decide how to handle it.
 ///
 /// # Generic Implementations
 ///