Skip to main content

devela/sys/mem/alloc/storage/
boxed.rs

1// devela::sys::mem::alloc::storage::boxed
2//
3//! *Boxed* storage
4//
5
6#[cfg(doc)]
7use crate::{Bare, BareBox};
8use crate::{Box, ConstInit, Storage};
9// #[cfg(feature = "dep_rkyv")] // DEP_DISABLED
10// use rkyv::{Archive, Deserialize, Serialize};
11
12#[doc = crate::_tags!(mem)]
13/// A zero-sized marker for a [`Storage`] type that wraps its data in a [`Box`].
14#[doc = crate::_doc_meta!{location("sys/mem/alloc")}]
15///
16/// Equivalent to the [`Bare`] marker struct which uses a [`BareBox`] for the underlying storage.
17// #[cfg_attr(feature = "dep_rkyv", derive(Archive, Serialize, Deserialize))]
18#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
19pub struct Boxed;
20
21/// This implementation is equivalent to the one for [`Bare`] which uses [`BareBox`] for storage.
22impl Storage for Boxed {
23    type Stored<T> = Box<T>;
24
25    fn name() -> &'static str {
26        "Boxed"
27    }
28}
29impl ConstInit for Boxed {
30    const INIT: Self = Boxed;
31}