Skip to content

Commit f488829

Browse files
committed
feat: move from #1875
1 parent 9420a82 commit f488829

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

libs/deer/src/impls/core.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ mod atomic;
33
mod bool;
44
mod floating;
55
mod integral;
6+
mod mem;
67
mod non_zero;
78
mod string;
89
mod unit;

libs/deer/src/impls/core/mem.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use core::mem::ManuallyDrop;
2+
3+
use error_stack::Result;
4+
5+
use crate::{error::DeserializeError, Deserialize, Deserializer, Document, Reflection, Schema};
6+
7+
impl<T: Reflection + ?Sized> Reflection for ManuallyDrop<T> {
8+
fn schema(doc: &mut Document) -> Schema {
9+
T::schema(doc)
10+
}
11+
}
12+
13+
impl<'de, T: Deserialize<'de>> Deserialize<'de> for ManuallyDrop<T> {
14+
type Reflection = ManuallyDrop<T::Reflection>;
15+
16+
fn deserialize<D: Deserializer<'de>>(de: D) -> Result<Self, DeserializeError> {
17+
T::deserialize(de).map(Self::new)
18+
}
19+
}

0 commit comments

Comments
 (0)