The guidelines below were approved by rust issue #7087.
[FIXME] Should we provide standard traits for conversions? Doing so nicely will require trait reform to land.
Conversions should be provided as methods, with names prefixed as follows:
&[u8]view into a
&str, which is a no-op.
&strto a new
Stringand yields the underlying
Vec<u8>, which is a no-op.
into_ typically decrease abstraction, either
exposing a view into the underlying representation (
as) or deconstructing data
into its underlying representation (
into). Conversions prefixed
to_, on the
other hand, typically stay at the same level of abstraction but do some work to
change one representation into another.
[FIXME] The distinctions between conversion methods does not work so well for
from_conversion constructors. Is that a problem?