Skip to content

Commit

Permalink
Relax trait bound for EitherCart in Yoke crate (#5876)
Browse files Browse the repository at this point in the history
The enum `EitherCart` in `Yoke` crate theoretically implements `Deref`
and `StableDeref` traits. However, it does not support the dereferenced
type `T` being Unsized (like `[u8]`). As a result, types like
`EitherCart<Arc<[u8]>, Box<[u8]>>` cause compiler errors, making this
enum less useful.

In this pull request, I have relaxed the trait bound of `T` to support
unsized types. This change should be safe as the origin `Deref` already
allows Unsized `T`.

---------

Co-authored-by: zhongyi51 <[email protected]>
  • Loading branch information
zhongyi51 and zhongyi51 authored Nov 30, 2024
1 parent b5b45a5 commit 7a7a89e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions utils/yoke/src/either.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ impl<C0, C1, T> Deref for EitherCart<C0, C1>
where
C0: Deref<Target = T>,
C1: Deref<Target = T>,
T: ?Sized,
{
type Target = T;
fn deref(&self) -> &T {
Expand All @@ -74,6 +75,7 @@ where
C1: StableDeref,
C0: Deref<Target = T>,
C1: Deref<Target = T>,
T: ?Sized,
{
}

Expand Down

0 comments on commit 7a7a89e

Please sign in to comment.