rok::core::convert
rok::core::convert: conversion traits (stdlib 2.11) and primitive
impls (2.11.8). Four policies, each named at the call: lossless into,
fallible try_into (throws TryFrom::Error, OverflowError for
numbers), saturating_into, and wrapping_into (= as).
The spec writes trait Into<T> { fn into(self) -> T; }, but a blanket
impl<T, U: From<T>> Into<U> for T cannot fix U from the receiver,
so each *Into trait has one generic method (T from the expected
type, like parse) and one blanket impl; the conversions are the
*From impls. SaturatingFrom / WrappingFrom back the last two
policies. The lossless impls are also rok.cast.* intrinsics
(2.11.12); their bodies are the same as.
Traits
From
pub trait From<U>A lossless conversion from U (2.11.2).
fn from(value: U) -> Self
Into
pub trait Intox.into() = T::from(x) (2.11.3); T from the expected type.
fn into<T: From<Self>>(self) -> T
TryFrom
pub trait TryFrom<U>A conversion that can fail (2.11.4). Error is what it throws:
ConversionError unless the impl names another (the numeric impls
say OverflowError).
type Error = ConversionErrorfn try_from(value: U) throws (Self::Error) -> Self
TryInto
pub trait TryIntox.try_into() = T::try_from(x) (2.11.4); throws T's Error.
fn try_into<T: TryFrom<Self>>(self) throws (T::Error) -> T
SaturatingFrom
pub trait SaturatingFrom<U>Out-of-range values clamp to the nearest end (2.11.5).
fn saturating_from(value: U) -> Self
SaturatingInto
pub trait SaturatingIntofn saturating_into<T: SaturatingFrom<Self>>(self) -> T
WrappingFrom
pub trait WrappingFrom<U>Keep the low bits - as spelled as a method (2.11.5).
fn wrapping_from(value: U) -> Self
WrappingInto
pub trait WrappingIntofn wrapping_into<T: WrappingFrom<Self>>(self) -> T