comprehensive-rust icon indicating copy to clipboard operation
comprehensive-rust copied to clipboard

`From` and `Into` slide should emphasize losslessness and infallibility

Open fw-immunant opened this issue 1 year ago • 0 comments

The standard library docs mention this:

The From trait is intended for perfect conversions. If the conversion can fail or is not perfect, use TryFrom.

But it's easy to miss one line in the docs; I think we should emphasize this in the speaker notes. It also isn't necessarily obvious what "perfect" means, so I think "lossless" is a better way to describe the contract of these traits. This is worth underlining because the commonsense notion of being able to convert between types may also apply to things like C-style casts that truncate and are not appropriate for these traits.

fw-immunant avatar May 09 '24 13:05 fw-immunant