When in doubt, prefer to_`to_/`/as_`as_/`/into_`into_to` to from_`from_`, because they are
more ergonomic to use (and can be chained with other methods).
For many conversions between two types, one of the types is clearly more
"specific": it provides some additional invariant or interpretation that is not
present in the other type. For example, str`stris more specific than` is more specific than &[u8]`&[u8]`,
since it is a utf-8 encoded sequence of bytes.
Conversions should live with the more specific of the involved types. Thus,
str`strprovides both the` provides both the as_bytes`as_bytesmethod and the` method and the from_utf8`from_utf8constructor for converting to and from` constructor for
converting to and from &[u8]`&[u8]values. Besides being intuitive, this convention avoids polluting concrete types like` values. Besides being intuitive, this convention
avoids polluting concrete types like &[u8]`&[u8]` with endless conversion methods.
If a function's name implies that it is a conversion (prefix from_`from_,`, as_`as_,`,
to_`to_or` or into_`into_), but the function loses information, add a suffix`), but the function loses information, add a suffix _lossy`_lossy` or
otherwise indicate the lossyness. Consider avoiding the conversion name prefix.