Skip to content

Commit 7866c8d

Browse files
committed
Implement Encode and RefEncode for Wrapping<T>
1 parent 5c7ac92 commit 7866c8d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

objc2_encode/src/encode.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use core::ffi::c_void;
22
use core::mem::ManuallyDrop;
33
use core::num::{
44
NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI8, NonZeroIsize, NonZeroU16, NonZeroU32,
5-
NonZeroU64, NonZeroU8, NonZeroUsize,
5+
NonZeroU64, NonZeroU8, NonZeroUsize, Wrapping,
66
};
77
use core::pin::Pin;
88
use core::ptr::NonNull;
@@ -314,6 +314,16 @@ unsafe impl<T: RefEncode> RefEncode for Pin<T> {
314314
const ENCODING_REF: Encoding<'static> = T::ENCODING_REF;
315315
}
316316

317+
// SAFETY: `Wrapping` is `repr(transparent)`.
318+
unsafe impl<T: Encode> Encode for Wrapping<T> {
319+
const ENCODING: Encoding<'static> = T::ENCODING;
320+
}
321+
322+
// SAFETY: `Wrapping` is `repr(transparent)`.
323+
unsafe impl<T: RefEncode> RefEncode for Wrapping<T> {
324+
const ENCODING_REF: Encoding<'static> = T::ENCODING_REF;
325+
}
326+
317327
/// Helper for implementing `Encode`/`RefEncode` for pointers to types that
318328
/// implement `RefEncode`.
319329
///

0 commit comments

Comments
 (0)