Manishearth/triomphe

Add unsizing support.

thomcc opened this issue · 1 comments

Something along these lines would add it, I think:

#![cfg_attr(
    feature = "unstable",
    feature(coerce_unsized, unsize, dispatch_from_dyn)
)]
#[cfg(feature = "unstable")]
use core::{
    marker::Unsize,
    ops::{CoerceUnsized, DispatchFromDyn},
};

#[cfg(feature = "unstable")]
impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<Arc<U>> for Arc<T> {}
#[cfg(feature = "unstable")]
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Arc<U>> for Arc<T> {}
#[cfg(feature = "unstable")]
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<UniqueArc<U>> for UniqueArc<T> {}

My hesitation is that I don't fully understand DispatchFromDyn, nor do I understand all the implications of these traits. I also don't need it myself.

DispatchFromDyn means that you can have methods that accept self: triomphe::Arc<Self> and have that be object safe