Trait mem_dbg::CopyType

source ·
pub trait CopyType {
    type Copy: Boolean;
}
Expand description

Marker trait for copy types.

The trait comes in two flavors: CopyType<Copy=True> and CopyType<Copy=False>. In the first case, MemSize::mem_size can be computed on arrays, vectors, and slices by multiplying the length or capacity by the size of the element type; in the second case, it is necessary to iterate on each element.

The trait is made necessary by the impossibility of checking that a type implements Copy from a procedural macro.

Since we cannot use negative trait bounds, every type that is used as a parameter of an array, vector, or slice must implement either CopyType<Copy=True> or CopyType<Copy=False>. If you do not implement either of these traits, you will not be able to compute the size of arrays, vectors, and slices but error messages will be very unhelpful due to the contrived way we have to implement mutually exclusive types working around the bug that prevents the compiler from understanding that implementations for the two flavors of CopyType are mutually exclusive.

If you use the provided derive macros all this logic will be hidden from you. You’ll just have to add the attribute #[copy_type] to your structures if they are Copy types and they do not contain references. We enforce this property by adding a bound Copy + 'static to the type in the procedural macro.

Note that this approach forces us to compute the size of Copy types that contain references by iteration even if you do not specify SizeFlags::FOLLOW_REFS.

Required Associated Types§

Implementations on Foreign Types§

source§

impl CopyType for bool

§

type Copy = True

source§

impl CopyType for char

§

type Copy = True

source§

impl CopyType for f32

§

type Copy = True

source§

impl CopyType for f64

§

type Copy = True

source§

impl CopyType for i8

§

type Copy = True

source§

impl CopyType for i16

§

type Copy = True

source§

impl CopyType for i32

§

type Copy = True

source§

impl CopyType for i64

§

type Copy = True

source§

impl CopyType for i128

§

type Copy = True

source§

impl CopyType for isize

§

type Copy = True

source§

impl CopyType for str

§

type Copy = False

source§

impl CopyType for u8

§

type Copy = True

source§

impl CopyType for u16

§

type Copy = True

source§

impl CopyType for u32

§

type Copy = True

source§

impl CopyType for u64

§

type Copy = True

source§

impl CopyType for u128

§

type Copy = True

source§

impl CopyType for ()

§

type Copy = True

source§

impl CopyType for usize

§

type Copy = True

source§

impl CopyType for String

§

type Copy = False

source§

impl CopyType for Layout

§

type Copy = True

source§

impl CopyType for PhantomPinned

§

type Copy = True

source§

impl CopyType for AtomicBool

§

type Copy = True

source§

impl CopyType for AtomicI8

§

type Copy = True

source§

impl CopyType for AtomicI16

§

type Copy = True

source§

impl CopyType for AtomicI32

§

type Copy = True

source§

impl CopyType for AtomicI64

§

type Copy = True

source§

impl CopyType for AtomicIsize

§

type Copy = True

source§

impl CopyType for AtomicU8

§

type Copy = True

source§

impl CopyType for AtomicU16

§

type Copy = True

source§

impl CopyType for AtomicU32

§

type Copy = True

source§

impl CopyType for AtomicU64

§

type Copy = True

source§

impl CopyType for AtomicUsize

§

type Copy = True

source§

impl CopyType for OsStr

§

type Copy = False

source§

impl CopyType for OsString

§

type Copy = False

source§

impl CopyType for File

§

type Copy = False

source§

impl CopyType for FileTimes

§

type Copy = False

source§

impl CopyType for FileType

§

type Copy = False

source§

impl CopyType for Metadata

§

type Copy = False

source§

impl CopyType for OpenOptions

§

type Copy = False

source§

impl CopyType for Permissions

§

type Copy = False

source§

impl CopyType for RandomState

§

type Copy = True

source§

impl CopyType for Path

§

type Copy = False

source§

impl CopyType for PathBuf

§

type Copy = False

source§

impl CopyType for NonZeroI8

§

type Copy = True

source§

impl CopyType for NonZeroI16

§

type Copy = True

source§

impl CopyType for NonZeroI32

§

type Copy = True

source§

impl CopyType for NonZeroI64

§

type Copy = True

source§

impl CopyType for NonZeroI128

§

type Copy = True

source§

impl CopyType for NonZeroIsize

§

type Copy = True

source§

impl CopyType for NonZeroU8

§

type Copy = True

source§

impl CopyType for NonZeroU16

§

type Copy = True

source§

impl CopyType for NonZeroU32

§

type Copy = True

source§

impl CopyType for NonZeroU64

§

type Copy = True

source§

impl CopyType for NonZeroU128

§

type Copy = True

source§

impl CopyType for NonZeroUsize

§

type Copy = True

source§

impl<A, B, C, D, R> CopyType for fn(_: A, _: B, _: C, _: D) -> R

§

type Copy = True

source§

impl<A, B, C, R> CopyType for fn(_: A, _: B, _: C) -> R

§

type Copy = True

source§

impl<A, B, R> CopyType for fn(_: A, _: B) -> R

§

type Copy = True

source§

impl<A, R> CopyType for fn(_: A) -> R

§

type Copy = True

source§

impl<H> CopyType for BuildHasherDefault<H>

§

type Copy = True

source§

impl<Idx: CopyType> CopyType for Range<Idx>

§

type Copy = True

source§

impl<Idx: CopyType> CopyType for RangeFrom<Idx>

§

type Copy = True

source§

impl<Idx: CopyType> CopyType for RangeInclusive<Idx>

§

type Copy = True

source§

impl<Idx: CopyType> CopyType for RangeTo<Idx>

§

type Copy = True

source§

impl<Idx: CopyType> CopyType for RangeToInclusive<Idx>

§

type Copy = True

source§

impl<R> CopyType for fn() -> R

§

type Copy = True

source§

impl<T0> CopyType for (T0,)

§

type Copy = False

source§

impl<T0, T1> CopyType for (T0, T1)

§

type Copy = False

source§

impl<T0, T1, T2> CopyType for (T0, T1, T2)

§

type Copy = False

source§

impl<T0, T1, T2, T3> CopyType for (T0, T1, T2, T3)

§

type Copy = False

source§

impl<T0, T1, T2, T3, T4> CopyType for (T0, T1, T2, T3, T4)

§

type Copy = False

source§

impl<T0, T1, T2, T3, T4, T5> CopyType for (T0, T1, T2, T3, T4, T5)

§

type Copy = False

source§

impl<T0, T1, T2, T3, T4, T5, T6> CopyType for (T0, T1, T2, T3, T4, T5, T6)

§

type Copy = False

source§

impl<T0, T1, T2, T3, T4, T5, T6, T7> CopyType for (T0, T1, T2, T3, T4, T5, T6, T7)

§

type Copy = False

source§

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8> CopyType for (T0, T1, T2, T3, T4, T5, T6, T7, T8)

§

type Copy = False

source§

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> CopyType for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)

§

type Copy = False

source§

impl<T> CopyType for Vec<T>

§

type Copy = False

source§

impl<T> CopyType for PhantomData<T>

§

type Copy = True

source§

impl<T> CopyType for Cursor<T>

§

type Copy = False

source§

impl<T: CopyType + MemSize> CopyType for Option<T>

§

type Copy = <T as CopyType>::Copy

source§

impl<T: CopyType + MemSize, const N: usize> CopyType for [T; N]

§

type Copy = <T as CopyType>::Copy

source§

impl<T: CopyType> CopyType for OnceCell<T>

§

type Copy = <T as CopyType>::Copy

source§

impl<T: CopyType> CopyType for Cell<T>

§

type Copy = <T as CopyType>::Copy

source§

impl<T: CopyType> CopyType for RefCell<T>

§

type Copy = <T as CopyType>::Copy

source§

impl<T: CopyType> CopyType for UnsafeCell<T>

§

type Copy = <T as CopyType>::Copy

source§

impl<T: CopyType> CopyType for Mutex<T>

§

type Copy = False

source§

impl<T: CopyType> CopyType for MutexGuard<'_, T>

§

type Copy = False

source§

impl<T: CopyType> CopyType for RwLock<T>

§

type Copy = False

source§

impl<T: CopyType> CopyType for RwLockReadGuard<'_, T>

§

type Copy = False

source§

impl<T: CopyType> CopyType for RwLockWriteGuard<'_, T>

§

type Copy = False

source§

impl<T: MemSize + Read> CopyType for BufReader<T>

§

type Copy = False

source§

impl<T: MemSize + Write> CopyType for BufWriter<T>

§

type Copy = False

source§

impl<T: ?Sized + MemSize> CopyType for &T

§

type Copy = False

source§

impl<T: ?Sized + MemSize> CopyType for &mut T

§

type Copy = False

source§

impl<T: ?Sized> CopyType for NonNull<T>

§

type Copy = True

Implementors§