Open scottlamb opened 7 years ago
Hi, I'm sincerely sorry for taking so long to respond.
Yeah, the marker traits are always tricky to support properly. Really makes me wish we could be generic over traits and trait bounds, as you could then write something like this:
unsafe trait IntoErased<'a, Trait: ?Sized> {
type Erased;
fn into_erased(self) -> Self::Erased;
}
unsafe impl<'a, T: 'a, Trait: ?Sized, T: Trait> IntoErased<'a, Trait> for Box<T> {
type Erased = Box<Trait + 'a>;
fn into_erased(self) -> Self::Erased {
self
}
}
let a = owning_ref.erase_owner<Erased>();
let b = owning_ref.erase_owner<ErasedSend>();
// ...
But I think it should still be possible to support somewhat conveniently by refactoring the typedefs a bit
Hi, I'm sincerely sorry for taking so long to respond.
No worries—I don't have a leg to stand on complaining about such things.
If you're looking for a co-maintainer for owning-ref
, I wonder if @diwic would be interested? I found diwic's similar reffers
crate shortly after filing this issue. For the hyper body chunk use case I described, reffers::ARefs<[u8]>
worked out quite well—functionally similar to having an enum of the various owner types using owning_ref
.
ErasedBoxRef
andErasedArcRef
aren'tSend
. Would it be possible to have very similar types which are? I guess with a method similar toerase_owner
to create them?Context: I proposed using these types to back hyper's
http::Chunk
, so that I can do such things as subsetting vectors as I put them into aChunk
or pass inmmap
-backed chunks. ButChunk
must be passable between threads, so this doesn't compile.@seanmonstar doesn't seem too thrilled with my proposal, so this probably won't happen regardless, but I imagine there are other situations where erased types are desirable but so is passing between threads. In fact,
ErasedArcRef
seems basically useless as-is;Send
is the point of usingArc
rather thanRc
.