[−][src]Struct gharial::TestBox
TestBox behaves like std::boxed::Box except for it owns a reference to a GlobalAlloc .
The default type of the GlobalAlloc reference is &TestAlloc .
Unlike to std::boxed::Box , it cause an assertion error when the GlobalAlloc is dropped
unless TestBox is surely dropped.
For example, it sometimes requires to allocate heap memory to implement container struct,
and then the elements must be dropped manually. TestBox helps the test to make sure the elements
are dropped.
Implementations
impl<'a, T, A> TestBox<'a, T, A> where
A: GlobalAlloc, [src]
A: GlobalAlloc,
pub fn new(x: T, alloc: &'a A) -> Self[src]
Creates a new instance.
pub unsafe fn from_raw_alloc(ptr: *mut T, alloc: &'a A) -> Self[src]
Creates a new instance from raw pointer and a reference to allocator.
After calling this function, the raw pointer is owned by the resulting TestBox .
Specifically, TestBox::drop destructs the referenced object and free the pointer.
Safety
To use this function safe, the ptr should be allocated via alloc and it should not be
freed anywhere else.
impl<'a, T, A> TestBox<'a, T, A> where
A: GlobalAlloc, [src]
A: GlobalAlloc,
pub fn leak(tb: Self) -> &'a mut T where
T: 'a, [src]
T: 'a,
Consumes and leaks TestBox .
pub fn into_raw(tb: Self) -> *mut T[src]
Consumes the TestBox and returning a wrapped raw pointer.
Trait Implementations
impl<T, A, '_> AsMut<T> for TestBox<'_, T, A> where
A: GlobalAlloc, [src]
A: GlobalAlloc,
impl<T, A, '_> AsRef<T> for TestBox<'_, T, A> where
A: GlobalAlloc, [src]
A: GlobalAlloc,
impl<T, A, '_> Borrow<T> for TestBox<'_, T, A> where
A: GlobalAlloc, [src]
A: GlobalAlloc,
impl<T, A, '_> BorrowMut<T> for TestBox<'_, T, A> where
A: GlobalAlloc, [src]
A: GlobalAlloc,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T, A, '_> Clone for TestBox<'_, T, A> where
T: Clone,
A: GlobalAlloc, [src]
T: Clone,
A: GlobalAlloc,
fn clone(&self) -> Self[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]
impl<T, A, '_> Deref for TestBox<'_, T, A> where
A: GlobalAlloc, [src]
A: GlobalAlloc,
impl<T, A, '_> DerefMut for TestBox<'_, T, A> where
A: GlobalAlloc, [src]
A: GlobalAlloc,
impl<T, A, '_> Drop for TestBox<'_, T, A> where
A: GlobalAlloc, [src]
A: GlobalAlloc,
impl<T, A, '_> Eq for TestBox<'_, T, A> where
T: Eq,
A: GlobalAlloc, [src]
T: Eq,
A: GlobalAlloc,
impl<T, A, '_> Hash for TestBox<'_, T, A> where
T: Hash,
A: GlobalAlloc, [src]
T: Hash,
A: GlobalAlloc,
fn hash<H>(&self, state: &mut H) where
H: Hasher, [src]
H: Hasher,
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
impl<T, A, '_> Ord for TestBox<'_, T, A> where
T: Ord,
A: GlobalAlloc, [src]
T: Ord,
A: GlobalAlloc,
fn cmp(&self, rh: &Self) -> Ordering[src]
#[must_use]fn max(self, other: Self) -> Self1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self[src]
impl<T, A, '_> PartialEq<TestBox<'_, T, A>> for TestBox<'_, T, A> where
T: PartialEq,
A: GlobalAlloc, [src]
T: PartialEq,
A: GlobalAlloc,
impl<T, A, '_> PartialOrd<TestBox<'_, T, A>> for TestBox<'_, T, A> where
T: PartialOrd,
A: GlobalAlloc, [src]
T: PartialOrd,
A: GlobalAlloc,
Auto Trait Implementations
impl<'a, T, A> RefUnwindSafe for TestBox<'a, T, A> where
A: RefUnwindSafe,
T: RefUnwindSafe,
A: RefUnwindSafe,
T: RefUnwindSafe,
impl<'a, T, A = TestAlloc<System>> !Send for TestBox<'a, T, A>
impl<'a, T, A = TestAlloc<System>> !Sync for TestBox<'a, T, A>
impl<'a, T, A> Unpin for TestBox<'a, T, A>
impl<'a, T, A> UnwindSafe for TestBox<'a, T, A> where
A: RefUnwindSafe,
T: RefUnwindSafe,
A: RefUnwindSafe,
T: RefUnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>, [src]
V: MultiLane<T>,