pub trait TryInto<T>:Sized { typeError; // Required method fntry_into(self) ->Result<T, Self::Error>;}Expand description
An attempted conversion that consumesself, which may or may not beexpensive.
Library authors should usually not directly implement this trait,but should prefer implementing theTryFrom trait, which offersgreater flexibility and provides an equivalentTryIntoimplementation for free, thanks to a blanket implementation in thestandard library. For more information on this, see thedocumentation forInto.
Prefer usingTryInto overTryFrom when specifying trait bounds on a generic functionto ensure that types that only implementTryInto can be used as well.
§ImplementingTryInto
This suffers the same restrictions and reasoning as implementingInto, see there for details.
Required Associated Types§
Required Methods§
Dyn Compatibility§
This trait isnotdyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.