use crate::{downcast::Downcast, upcast::Upcast};
use super::*;
pub trait Veecast<To, Obj>: VeecastRef<To>
where
To: ?Sized,
Obj: ?Sized
{
fn veecast<Struct>(self: Box<Self>) -> Result<Box<To>, Box<Obj>>
where
Self: Downcast<Struct, Obj>,
Struct: Upcast<To>;
}
impl<From, To, Obj> Veecast<To, Obj> for From
where
From: ?Sized,
To: ?Sized,
Obj: ?Sized
{
fn veecast<Struct>(self: Box<Self>) -> Result<Box<To>, Box<Obj>>
where
Self: Downcast<Struct, Obj>,
Struct: Upcast<To>
{
self.downcast().map(|vee| vee.upcast())
}
}