about summary refs log tree commit diff
diff options
context:
space:
mode:
authorscottmcm <scottmcm@users.noreply.github.com>2023-10-06 05:31:54 +0000
committerGitHub <noreply@github.com>2023-10-06 05:31:54 +0000
commit44f92c1f805434866b9744a6c8953ecdd8cc36f9 (patch)
treeb5a863a297670235c8294b12cacd1e3e86c3df6f
parentb80e653ca1278a2c4fa411b938be1ccc7ed204fb (diff)
downloadrust-44f92c1f805434866b9744a6c8953ecdd8cc36f9.tar.gz
rust-44f92c1f805434866b9744a6c8953ecdd8cc36f9.zip
Don't mention "recover the original" in `From` docs
Co-authored-by: Josh Triplett <josh@joshtriplett.org>
-rw-r--r--library/core/src/convert/mod.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/library/core/src/convert/mod.rs b/library/core/src/convert/mod.rs
index db9f7237bd6..aed5552ef91 100644
--- a/library/core/src/convert/mod.rs
+++ b/library/core/src/convert/mod.rs
@@ -484,8 +484,11 @@ pub trait Into<T>: Sized {
 /// a `From` implementation, the general expectation is that the conversions
 /// should typically be restricted as follows:
 ///
-/// * The conversion is *lossless*: it cannot fail and it's possible to recover
-///   the original value.  For example, `i32: From<u16>` exists, where the original
+/// * The conversion is *infallible*: if the conversion can fail, use `TryFrom`
+///   instead; don't provide a `From` impl that panics.
+///
+/// * The conversion is *lossless*: semantically, it should not lose or discard
+///   information. For example, `i32: From<u16>` exists, where the original
 ///   value can be recovered using `u16: TryFrom<i32>`.  And `String: From<&str>`
 ///   exists, where you can get something equivalent to the original value via
 ///   `Deref`.  But `From` cannot be used to convert from `u32` to `u16`, since