miniserde/opt/rustwide/target/x86_64-unknown-linux-gnu/debug/build/miniserde-b9678e2d8797835e/out/place.rs
1/// Macro to define a "place" type compatible with deserialization.
2///
3/// [Refer to the `miniserde::de` documentation for examples.][crate::de]
4///
5/// This macro expands to:
6///
7/// ```rust
8/// # macro_rules! make_place {
9/// # ($name:ident) => {
10/// struct $name<T> {
11/// out: Option<T>,
12/// }
13///
14/// impl<T> $name<T> {
15/// fn new(out: &mut Option<T>) -> &mut Self {
16/// /* ... */
17/// # unimplemented!()
18/// }
19/// }
20/// # };
21/// # }
22/// #
23/// # make_place!(Place);
24/// ```
25#[macro_export]
26macro_rules! make_place {
27 ($name:ident) => {
28 #[repr(C)]
29 struct $name<__T> {
30 out: $crate::__private45::Option<__T>,
31 }
32
33 impl<__T> $name<__T> {
34 fn new(out: &mut $crate::__private45::Option<__T>) -> &mut Self {
35 unsafe { &mut *$crate::__private45::ptr::addr_of_mut!(*out).cast::<$name<__T>>() }
36 }
37 }
38 };
39}