rkyv/impls/alloc/
niche.rs1use crate::{niche::option_box::ArchivedOptionBox, ArchivePointee};
2#[cfg(not(feature = "std"))]
3use ::alloc::boxed::Box;
4
5impl<T, U> PartialEq<Option<Box<T>>> for ArchivedOptionBox<U>
6where
7 T: ?Sized,
8 U: ArchivePointee + PartialEq<T> + ?Sized,
9{
10 #[inline]
11 fn eq(&self, other: &Option<Box<T>>) -> bool {
12 if let Some(self_value) = self.as_deref() {
13 if let Some(other_value) = other.as_deref() {
14 self_value.eq(other_value)
15 } else {
16 false
17 }
18 } else {
19 other.is_none()
20 }
21 }
22}
23
24impl<T, U> PartialEq<ArchivedOptionBox<T>> for Option<Box<U>>
25where
26 T: ArchivePointee + PartialEq<U> + ?Sized,
27 U: ?Sized,
28{
29 #[inline]
30 fn eq(&self, other: &ArchivedOptionBox<T>) -> bool {
31 other.eq(self)
32 }
33}