stackbox/
lib.rs

1//! [`StackBox`]: `StackBox`
2//!
3#![doc = include_str!("../README.md")]
4#![cfg_attr(
5    not(any(doc, feature = "std", test)),
6    no_std,
7)]
8
9#![allow(unused_parens)]
10#![deny(rust_2018_idioms)]
11#![allow(explicit_outlives_requirements)] // much unsafe code; better safe than sorry
12
13#[cfg(feature = "alloc")]
14extern crate alloc;
15
16#[cfg(test)]
17extern crate self as stackbox;
18
19pub
20mod dyn_traits;
21
22mod marker;
23
24mod ptr;
25
26pub use slot::{mk_slot, Slot};
27mod slot;
28
29pub use stackbox_mod::{StackBox, slice};
30#[path = "stackbox/mod.rs"]
31mod stackbox_mod;
32
33/// This crates prelude: usage of this crate is designed to be ergonomic
34/// provided all the items within this module are in scope.
35pub
36mod prelude {
37    #[doc(no_inline)]
38    pub use crate::{
39        custom_dyn,
40        dyn_traits::{
41            any::StackBoxDynAny,
42            fn_once::*,
43        },
44        mk_slot,
45        mk_slots,
46        stackbox,
47        StackBox,
48    };
49}
50
51#[doc(hidden)] /** Macro internals, not subject to semver rules */ pub
52mod __ {
53    pub use ::core::{
54        marker::Sized,
55        mem::ManuallyDrop,
56    };
57
58    pub trait GetVTable {
59        type VTable;
60    }
61    pub use ::core::{
62        concat,
63        marker::{PhantomData, Send, Sync},
64        mem::transmute,
65        ops::Drop,
66    };
67    pub use ::paste::paste;
68    pub use crate::{
69        marker::{Sendness::T as Sendness, Syncness::T as Syncness, NoAutoTraits},
70        dyn_traits::__::DynCoerce,
71    };
72    mod ty { pub struct Erased(()); }
73    pub type ErasedPtr = ::core::ptr::NonNull<ty::Erased>;
74
75    pub
76    unsafe fn drop_in_place<T> (ptr: ErasedPtr)
77    {
78        ::core::ptr::drop_in_place::<T>(ptr.cast::<T>().as_ptr());
79    }
80}