File tree 1 file changed +5
-2
lines changed
1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -484,15 +484,18 @@ pub trait Into<T>: Sized {
484
484
/// a `From` implementation, the general expectation is that the conversions
485
485
/// should typically be restricted as follows:
486
486
///
487
- /// * The conversion is *infallible*: if the conversion can fail, use `TryFrom`
487
+ /// * The conversion is *infallible*: if the conversion can fail, use [ `TryFrom`]
488
488
/// instead; don't provide a `From` impl that panics.
489
489
///
490
490
/// * The conversion is *lossless*: semantically, it should not lose or discard
491
491
/// information. For example, `i32: From<u16>` exists, where the original
492
492
/// value can be recovered using `u16: TryFrom<i32>`. And `String: From<&str>`
493
493
/// exists, where you can get something equivalent to the original value via
494
494
/// `Deref`. But `From` cannot be used to convert from `u32` to `u16`, since
495
- /// that cannot succeed in a lossless way.
495
+ /// that cannot succeed in a lossless way. (There's some wiggle room here for
496
+ /// information not considered semantically relevant. For example,
497
+ /// `Box<[T]>: From<Vec<T>>` exists even though it might not preserve capacity,
498
+ /// like how two vectors can be equal despite differing capacities.)
496
499
///
497
500
/// * The conversion is *value-preserving*: the conceptual kind and meaning of
498
501
/// the resulting value is the same, even though the Rust type and technical
You can’t perform that action at this time.
0 commit comments