Movatterモバイル変換


[0]ホーム

URL:


core::convert

TraitTryInto

1.34.0 (const:unstable) ·Source
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§

1.34.0 ·Source

typeError

The type returned in the event of a conversion error.

Required Methods§

1.34.0 ·Source

fntry_into(self) ->Result<T, Self::Error>

Performs the conversion.

Dyn Compatibility§

This trait isnotdyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

1.34.0 (const:unstable) ·Source§

impl<T, U>TryInto<U> for T
where U:TryFrom<T>,

Source§

typeError = <U asTryFrom<T>>::Error


[8]ページ先頭

©2009-2025 Movatter.jp