Skip to main content

TryConvert

Trait TryConvert 

Source
pub trait TryConvert<'ast, T>
where Self: Sized,
{ type Error; // Required method fn try_convert(alloc: &'ast AstAlloc, from: T) -> Result<Self, Self::Error>; }
Expand description

Similar to TryFrom, but takes an additional allocator for conversion from and to crate::ast::Ast that requires to thread an explicit allocator.

We chose a different name than try_from for the method - although it has a different signature from the standard TryFrom (two arguments vs one) - to avoid confusing the compiler which would otherwise have difficulties disambiguating calls like Ast::try_from.

Required Associated Types§

Required Methods§

Source

fn try_convert(alloc: &'ast AstAlloc, from: T) -> Result<Self, Self::Error>

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<T, U> TryConvert<'_, T> for U
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error