Skip to content

Commit d513f95

Browse files
n3vu0rmbrubeck
authored andcommitted
Assume POD and re-check NotNan.
1 parent dfbadaf commit d513f95

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/lib.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1740,26 +1740,30 @@ mod impl_rkyv {
17401740
}
17411741
}
17421742

1743+
#[cfg(feature = "rkyv_ck")]
1744+
use super::FloatIsNan;
1745+
#[cfg(feature = "rkyv_ck")]
1746+
use core::convert::Infallible;
17431747
#[cfg(feature = "rkyv_ck")]
17441748
use rkyv::bytecheck::CheckBytes;
17451749

17461750
#[cfg(feature = "rkyv_ck")]
1747-
impl<C: ?Sized, T: CheckBytes<C>> CheckBytes<C> for OrderedFloat<T> {
1748-
type Error = T::Error;
1751+
impl<C: ?Sized, T: Float + CheckBytes<C>> CheckBytes<C> for OrderedFloat<T> {
1752+
type Error = Infallible;
17491753

17501754
#[inline]
1751-
unsafe fn check_bytes<'a>(value: *const Self, c: &mut C) -> Result<&'a Self, Self::Error> {
1752-
T::check_bytes(value as *const T, c).map(|_| &*value)
1755+
unsafe fn check_bytes<'a>(value: *const Self, _: &mut C) -> Result<&'a Self, Self::Error> {
1756+
Ok(&*value)
17531757
}
17541758
}
17551759

17561760
#[cfg(feature = "rkyv_ck")]
1757-
impl<C: ?Sized, T: CheckBytes<C>> CheckBytes<C> for NotNan<T> {
1758-
type Error = T::Error;
1761+
impl<C: ?Sized, T: Float + CheckBytes<C>> CheckBytes<C> for NotNan<T> {
1762+
type Error = FloatIsNan;
17591763

17601764
#[inline]
1761-
unsafe fn check_bytes<'a>(value: *const Self, c: &mut C) -> Result<&'a Self, Self::Error> {
1762-
T::check_bytes(value as *const T, c).map(|_| &*value)
1765+
unsafe fn check_bytes<'a>(value: *const Self, _: &mut C) -> Result<&'a Self, Self::Error> {
1766+
Self::new(*(value as *const T)).map(|_| &*value)
17631767
}
17641768
}
17651769

0 commit comments

Comments
 (0)