I want to alias std::sync::Arc::downcast
for a trait:
use std::{any::Any, sync::Arc};
trait Node {
fn to<T: Any + Sync + Send>(self: Arc<Self>) -> Arc<T> where Self: 'static, Self: Send, Self: Sync, Self: Sized {
Arc::downcast::<T>(self).unwrap()
}
}
So this enables typing something like node.to::<Bitmap>()
. It works, but as you can see I was obligged to add a lot of bounds manually to Self
. Is there a way to simplify that?
P.S.: although that verbosity doesn't matter at all since in regards to subtype conversions I'll only provide to
and is
.