#[repr(C)]pub struct DebugOnly<T> {
pub _phantom_0: PhantomData<UnsafeCell<T>>,
pub value: T,
}Expand description
DebugOnly contains a value of type T, but only in debug builds. In release builds, it does not contain a value. This helper is intended to be used with MOZ_ASSERT()-style macros, allowing one to write:
DebugOnly
more concisely than declaring |check| conditional on #ifdef DEBUG.
DebugOnly instances can only be coerced to T in debug builds. In release builds they don’t have a value, so type coercion is not well defined.
NOTE: DebugOnly instances still take up one byte of space, plus padding, even in optimized, non-DEBUG builds (see bug 1253094 comment 37 for more info). For this reason the class is MOZ_STACK_CLASS to prevent consumers using DebugOnly for struct/class members and unwittingly inflating the size of their objects in release builds.
Fields§
§_phantom_0: PhantomData<UnsafeCell<T>>§value: TTrait Implementations§
impl<T> StructuralPartialEq for DebugOnly<T>
Auto Trait Implementations§
impl<T> Freeze for DebugOnly<T>where
T: Freeze,
impl<T> !RefUnwindSafe for DebugOnly<T>
impl<T> Send for DebugOnly<T>where
T: Send,
impl<T> !Sync for DebugOnly<T>
impl<T> Unpin for DebugOnly<T>where
T: Unpin,
impl<T> UnwindSafe for DebugOnly<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Filterable for T
impl<T> Filterable for T
Source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(DataRequest<'_>) -> bool>
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> MaybeSendSync for T
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.