Skip to main content

TryAs

Trait TryAs 

Source
pub trait TryAs<'a, T>: AsObject<'a> + TryInto<T, Error = Type>
where T: AsObject<'a> + TryFrom<Self, Error = Type>,
{ // Required method fn try_as(self) -> Result<T, Type>; }
Expand description

An abstraction for fallible casting between object types.

Implement TryFrom<Self, Error = Type> instead of implementing this trait directly.

Required Methods§

Source

fn try_as(self) -> Result<T, Type>

This function must follow the semantics of the AS3 as operator.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl<'a, O, T> TryAs<'a, T> for O
where O: AsObject<'a> + TryInto<T, Error = Type>, T: AsObject<'a> + TryFrom<O, Error = Type>,