someguynamedjosh/ouroboros

Support `?Sized`/unsizing coercions

SoniEx2 opened this issue · 2 comments

For feature-parity with selfref.

// cannot work, ?Sized must come last
#[self_referencing]
struct Foo<T: ?Sized> {
    x: T,
    #[borrows(x)]
    y: &'this dyn std::fmt::Debug,
}

// doesn't work, borrowees must come first
#[self_referencing]
struct Foo<T: ?Sized> {
    #[borrows(x)]
    y: &'this dyn std::fmt::Debug,
    x: T,
}

I cannot quite follow what’s the requested feature here. If you’re thinking of &Foo<[u8; N]> to &Foo<[u8]> coercions or the like, you’re probably missing the fact that all borrowed fields in an ouroboros self-referencing struct are implicitly put into a Box. So either way, x would need to become Box<T> which kills the unsizing due to the level of indirection, no matter the field order.

well, selfref can do it.