Skip to content

Commit a5e0731

Browse files
Don't mention "recover the original" in From docs
Co-authored-by: Josh Triplett <[email protected]>
1 parent dd654cf commit a5e0731

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

core/src/convert/mod.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -484,8 +484,11 @@ pub trait Into<T>: Sized {
484484
/// a `From` implementation, the general expectation is that the conversions
485485
/// should typically be restricted as follows:
486486
///
487-
/// * The conversion is *lossless*: it cannot fail and it's possible to recover
488-
/// the original value. For example, `i32: From<u16>` exists, where the original
487+
/// * The conversion is *infallible*: if the conversion can fail, use `TryFrom`
488+
/// instead; don't provide a `From` impl that panics.
489+
///
490+
/// * The conversion is *lossless*: semantically, it should not lose or discard
491+
/// information. For example, `i32: From<u16>` exists, where the original
489492
/// value can be recovered using `u16: TryFrom<i32>`. And `String: From<&str>`
490493
/// exists, where you can get something equivalent to the original value via
491494
/// `Deref`. But `From` cannot be used to convert from `u32` to `u16`, since

0 commit comments

Comments
 (0)