Skip to content

Commit

Permalink
auto import AsRef for Either
Browse files Browse the repository at this point in the history
  • Loading branch information
any committed Sep 17, 2022
1 parent b87a853 commit 8a568be
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions crates/napi/src/bindgen_runtime/js_values/either.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@ pub enum Either<A, B> {
B(B),
}

unsafe impl<A, B> Send for Either<A, B> {}
unsafe impl<A, B> Sync for Either<A, B> {}

impl<A: AsRef<T>, B: AsRef<T>, T> AsRef<T> for Either<A, B>
where
T: ?Sized,
{
fn as_ref(&self) -> &T {
match &self {
Self::A(a) => a.as_ref(),
Self::B(b) => b.as_ref(),
}
}
}

impl<A: NapiRaw, B: NapiRaw> Either<A, B> {
/// # Safety
/// Backward compatible with `Either` in **v1**
Expand Down

0 comments on commit 8a568be

Please sign in to comment.