pub struct TESBox<T: ?Sized, A: Allocator = TESGlobalAlloc>(/* private fields */);
Expand description
Heap memory allocation smart pointer that MemoryManager
malloc
and free
trigger by default.
The allocator side is always of type zero size and represents owned *mut ptr
. (i.e. size is type ptr)
§Examples
let five = TESBox::new(5);
Implementations§
Source§impl<T> TESBox<T>
impl<T> TESBox<T>
Sourcepub fn new(x: T) -> Self
pub fn new(x: T) -> Self
Allocates memory on the heap and then places x
into it.
This doesn’t actually allocate if T
is zero-sized.
§Examples
let five = TESBox::new(5);
Sourcepub fn new_uninit() -> TESBox<MaybeUninit<T>>
pub fn new_uninit() -> TESBox<MaybeUninit<T>>
Constructs a new box with uninitialized contents.
§Examples
let mut five = TESBox::<u32>::new_uninit();
// Deferred initialization:
five.write(5);
let five = unsafe { five.assume_init() };
assert_eq!(*five, 5)
Sourcepub fn try_new(x: T) -> Result<Self, AllocError>
pub fn try_new(x: T) -> Result<Self, AllocError>
Allocates memory on the heap then places x
into it,
returning an error if the allocation fails
This doesn’t actually allocate if T
is zero-sized.
§Examples
let five = TESBox::try_new(5)?;
Source§impl<T, A: Allocator> TESBox<T, A>
impl<T, A: Allocator> TESBox<T, A>
Sourcepub fn new_in(x: T, alloc: A) -> Selfwhere
A: Allocator,
pub fn new_in(x: T, alloc: A) -> Selfwhere
A: Allocator,
Allocates memory in the given allocator then places x
into it.
This doesn’t actually allocate if T
is zero-sized.
§Examples
use stdx::alloc::Global;
let five = TESBox::new_in(5, Global);
Sourcepub fn try_new_in(x: T, alloc: A) -> Result<Self, AllocError>where
A: Allocator,
pub fn try_new_in(x: T, alloc: A) -> Result<Self, AllocError>where
A: Allocator,
Allocates memory in the given allocator then places x
into it,
returning an error if the allocation fails
This doesn’t actually allocate if T
is zero-sized.
§Examples
use stdx::alloc::Global;
let five = TESBox::try_new_in(5, Global)?;
Sourcepub fn new_uninit_in(alloc: A) -> TESBox<MaybeUninit<T>, A>where
A: Allocator,
pub fn new_uninit_in(alloc: A) -> TESBox<MaybeUninit<T>, A>where
A: Allocator,
Constructs a new box with uninitialized contents in the provided allocator.
§Examples
use stdx::alloc::Global;
let mut five = TESBox::<u32, _>::new_uninit_in(Global);
// Deferred initialization:
five.write(5);
let five = unsafe { five.assume_init() };
assert_eq!(*five, 5)
Sourcepub fn try_new_uninit_in(
alloc: A,
) -> Result<TESBox<MaybeUninit<T>, A>, AllocError>where
A: Allocator,
pub fn try_new_uninit_in(
alloc: A,
) -> Result<TESBox<MaybeUninit<T>, A>, AllocError>where
A: Allocator,
Constructs a new box with uninitialized contents in the provided allocator, returning an error if the allocation fails
§Examples
use stdx::alloc::Global;
let mut five = TESBox::<u32, _>::try_new_uninit_in(Global)?;
// Deferred initialization:
five.write(5);
let five = unsafe { five.assume_init() };
assert_eq!(*five, 5);
Source§impl<T> TESBox<[T]>
impl<T> TESBox<[T]>
Sourcepub fn into_array<const N: usize>(self) -> Option<TESBox<[T; N]>>
pub fn into_array<const N: usize>(self) -> Option<TESBox<[T; N]>>
Converts the boxed slice into a boxed array.
This operation does not reallocate; the underlying array of the slice is simply reinterpreted as an array type.
If N
is not exactly equal to the length of self
, then this method returns None
.
Source§impl<T, A: Allocator> TESBox<MaybeUninit<T>, A>
impl<T, A: Allocator> TESBox<MaybeUninit<T>, A>
Sourcepub unsafe fn assume_init(self) -> TESBox<T, A>
pub unsafe fn assume_init(self) -> TESBox<T, A>
Converts to Box<T, A>
.
§Safety
As with MaybeUninit::assume_init
,
it is up to the caller to guarantee that the value
really is in an initialized state.
Calling this when the content is not yet fully initialized
causes immediate undefined behavior.
§Examples
let mut five = TESBox::<u32>::new_uninit();
// Deferred initialization:
five.write(5);
let five: TESBox<u32> = unsafe { five.assume_init() };
assert_eq!(*five, 5)
Sourcepub fn write(boxed: Self, value: T) -> TESBox<T, A>
pub fn write(boxed: Self, value: T) -> TESBox<T, A>
Writes the value and converts to Box<T, A>
.
This method converts the box similarly to Box::assume_init
but
writes value
into it before conversion thus guaranteeing safety.
In some scenarios use of this method may improve performance because
the compiler may be able to optimize copying from stack.
§Examples
let big_box = TESBox::<[usize; 1024]>::new_uninit();
let mut array = [0; 1024];
for (i, place) in array.iter_mut().enumerate() {
*place = i;
}
// The optimizer may be able to elide this copy, so previous code writes
// to heap directly.
let big_box = TESBox::write(big_box, array);
for (i, x) in big_box.iter().enumerate() {
assert_eq!(*x, i);
}
Source§impl<T: ?Sized> TESBox<T>
impl<T: ?Sized> TESBox<T>
Sourcepub const unsafe fn from_raw(raw: *mut T) -> Self
pub const unsafe fn from_raw(raw: *mut T) -> Self
Constructs a box from a raw pointer.
After calling this function, the raw pointer is owned by the
resulting Box
. Specifically, the Box
destructor will call
the destructor of T
and free the allocated memory. For this
to be safe, the memory must have been allocated in accordance
with the memory layout used by Box
.
§Safety
This function is unsafe because improper use may lead to memory problems. For example, a double-free may occur if the function is called twice on the same raw pointer.
The raw pointer must point to a block of memory allocated by the global allocator.
The safety conditions are described in the memory layout section.
§Examples
Recreate a Box
which was previously converted to a raw pointer
using Box::into_raw
:
let x = TESBox::new(5);
let ptr = TESBox::into_raw(x);
let x = unsafe { TESBox::from_raw(ptr) };
Manually create a Box
from scratch by using the global allocator:
use std::alloc::{alloc, Layout};
use stdx::alloc::{Allocator, Global};
use commonlibsse_ng::re::TESBox::TESBox;
unsafe {
let ptr = alloc(Layout::new::<i32>()) as *mut i32;
// In general .write is required to avoid attempting to destruct
// the (uninitialized) previous contents of `ptr`, though for this
// simple example `*ptr = 5` would have worked as well.
ptr.write(5);
let x = TESBox::from_raw(ptr);
}
Sourcepub unsafe fn from_non_null(ptr: NonNull<T>) -> Self
pub unsafe fn from_non_null(ptr: NonNull<T>) -> Self
Constructs a box from a NonNull
pointer.
After calling this function, the NonNull
pointer is owned by
the resulting Box
. Specifically, the Box
destructor will call
the destructor of T
and free the allocated memory. For this
to be safe, the memory must have been allocated in accordance
with the memory layout used by Box
.
§Safety
This function is unsafe because improper use may lead to
memory problems. For example, a double-free may occur if the
function is called twice on the same NonNull
pointer.
The non-null pointer must point to a block of memory allocated by the global allocator.
The safety conditions are described in the memory layout section.
§Examples
Recreate a Box
which was previously converted to a NonNull
pointer using Box::into_non_null
:
let x = TESBox::new(5);
let non_null = TESBox::into_non_null(x);
let x = unsafe { TESBox::from_non_null(non_null) };
Manually create a Box
from scratch by using the global allocator:
use stdx::alloc::{Allocator, Global};
use std::alloc::{alloc, Layout};
use std::ptr::NonNull;
use commonlibsse_ng::re::TESBox::TESBox;
unsafe {
let non_null = NonNull::new(alloc(Layout::new::<i32>()).cast::<i32>())
.expect("allocation failed");
// In general .write is required to avoid attempting to destruct
// the (uninitialized) previous contents of `non_null`.
non_null.write(5);
let x = TESBox::from_non_null(non_null);
}
Source§impl<T: ?Sized, A: Allocator> TESBox<T, A>
impl<T: ?Sized, A: Allocator> TESBox<T, A>
Sourcepub const unsafe fn from_raw_in(raw: *mut T, alloc: A) -> Self
pub const unsafe fn from_raw_in(raw: *mut T, alloc: A) -> Self
Constructs a box from a raw pointer in the given allocator.
After calling this function, the raw pointer is owned by the
resulting Box
. Specifically, the Box
destructor will call
the destructor of T
and free the allocated memory. For this
to be safe, the memory must have been allocated in accordance
with the memory layout used by Box
.
§Safety
This function is unsafe because improper use may lead to memory problems. For example, a double-free may occur if the function is called twice on the same raw pointer.
The raw pointer must point to a block of memory allocated by alloc
.
§Examples
Recreate a Box
which was previously converted to a raw pointer
using Box::into_raw_with_allocator
:
use stdx::alloc::Global;
let x = TESBox::new_in(5, Global);
let (ptr, alloc) = TESBox::into_raw_with_allocator(x);
let x = unsafe { TESBox::from_raw_in(ptr, alloc) };
Manually create a Box
from scratch by using the system allocator:
// use std::alloc::Layout;
// use stdx::alloc::{Allocator, Global};
// use commonlibsse_ng::re::TESBox::TESBox;
// unsafe {
// let ptr = Global.allocate(Layout::new::<i32>())?.as_mut_ptr() as *mut i32;
// // In general .write is required to avoid attempting to destruct
// // the (uninitialized) previous contents of `ptr`, though for this
// // simple example `*ptr = 5` would have worked as well.
// ptr.write(5);
// let x = TESBox::from_raw_in(ptr, Global);
// }
// # Ok::<(), stdx::alloc::AllocError>(())
Sourcepub const unsafe fn from_non_null_in(raw: NonNull<T>, alloc: A) -> Self
pub const unsafe fn from_non_null_in(raw: NonNull<T>, alloc: A) -> Self
Constructs a box from a NonNull
pointer in the given allocator.
After calling this function, the NonNull
pointer is owned by
the resulting Box
. Specifically, the Box
destructor will call
the destructor of T
and free the allocated memory. For this
to be safe, the memory must have been allocated in accordance
with the memory layout used by Box
.
§Safety
This function is unsafe because improper use may lead to memory problems. For example, a double-free may occur if the function is called twice on the same raw pointer.
The non-null pointer must point to a block of memory allocated by alloc
.
§Examples
Recreate a Box
which was previously converted to a NonNull
pointer
using Box::into_non_null_with_allocator
:
use stdx::alloc::Global;
use commonlibsse_ng::re::TESBox::TESBox;
let x = TESBox::new_in(5, Global);
let (non_null, alloc) = TESBox::into_non_null_with_allocator(x);
let x = unsafe { TESBox::from_non_null_in(non_null, alloc) };
Manually create a Box
from scratch by using the system allocator:
use std::alloc::Layout;
use stdx::alloc::{Allocator, Global};
use commonlibsse_ng::re::TESBox::TESBox;
unsafe {
let non_null = Global.allocate(Layout::new::<i32>())?.cast::<i32>();
// In general .write is required to avoid attempting to destruct
// the (uninitialized) previous contents of `non_null`.
non_null.write(5);
let x = TESBox::from_non_null_in(non_null, Global);
}
Sourcepub fn into_raw(b: Self) -> *mut T
pub fn into_raw(b: Self) -> *mut T
Consumes the Box
, returning a wrapped raw pointer.
The pointer will be properly aligned and non-null.
After calling this function, the caller is responsible for the
memory previously managed by the Box
. In particular, the
caller should properly destroy T
and release the memory, taking
into account the memory layout used by Box
. The easiest way to
do this is to convert the raw pointer back into a Box
with the
Box::from_raw
function, allowing the Box
destructor to perform
the cleanup.
Note: this is an associated function, which means that you have
to call it as Box::into_raw(b)
instead of b.into_raw()
. This
is so that there is no conflict with a method on the inner type.
§Examples
Converting the raw pointer back into a Box
with Box::from_raw
for automatic cleanup:
let x = TESBox::new(String::from("Hello"));
let ptr = TESBox::into_raw(x);
let x = unsafe { TESBox::from_raw(ptr) };
Manual cleanup by explicitly running the destructor and deallocating the memory:
use std::alloc::{dealloc, Layout};
use std::ptr;
let x = TESBox::new(String::from("Hello"));
let ptr = TESBox::into_raw(x);
unsafe {
ptr::drop_in_place(ptr);
dealloc(ptr as *mut u8, Layout::new::<String>());
}
Note: This is equivalent to the following:
let x = TESBox::new(String::from("Hello"));
let ptr = TESBox::into_raw(x);
unsafe {
drop(TESBox::from_raw(ptr));
}
Sourcepub fn into_non_null(b: Self) -> NonNull<T>
pub fn into_non_null(b: Self) -> NonNull<T>
Consumes the Box
, returning a wrapped NonNull
pointer.
The pointer will be properly aligned.
After calling this function, the caller is responsible for the
memory previously managed by the Box
. In particular, the
caller should properly destroy T
and release the memory, taking
into account the memory layout used by Box
. The easiest way to
do this is to convert the NonNull
pointer back into a Box
with the
Box::from_non_null
function, allowing the Box
destructor to
perform the cleanup.
Note: this is an associated function, which means that you have
to call it as Box::into_non_null(b)
instead of b.into_non_null()
.
This is so that there is no conflict with a method on the inner type.
§Examples
Converting the NonNull
pointer back into a Box
with Box::from_non_null
for automatic cleanup:
use commonlibsse_ng::re::TESBox::TESBox;
let x = TESBox::new(String::from("Hello"));
let non_null = TESBox::into_non_null(x);
let x = unsafe { TESBox::from_non_null(non_null) };
Manual cleanup by explicitly running the destructor and deallocating the memory:
use std::alloc::{dealloc, Layout};
use commonlibsse_ng::re::TESBox::TESBox;
let x = TESBox::new(String::from("Hello"));
let non_null = TESBox::into_non_null(x);
unsafe {
non_null.drop_in_place();
dealloc(non_null.as_ptr().cast::<u8>(), Layout::new::<String>());
}
Note: This is equivalent to the following:
use commonlibsse_ng::re::TESBox::TESBox;
let x = TESBox::new(String::from("Hello"));
let non_null = TESBox::into_non_null(x);
unsafe {
drop(TESBox::from_non_null(non_null));
}
Sourcepub fn into_raw_with_allocator(b: Self) -> (*mut T, A)
pub fn into_raw_with_allocator(b: Self) -> (*mut T, A)
Consumes the Box
, returning a wrapped raw pointer and the allocator.
The pointer will be properly aligned and non-null.
After calling this function, the caller is responsible for the
memory previously managed by the Box
. In particular, the
caller should properly destroy T
and release the memory, taking
into account the memory layout used by Box
. The easiest way to
do this is to convert the raw pointer back into a Box
with the
Box::from_raw_in
function, allowing the Box
destructor to perform
the cleanup.
Note: this is an associated function, which means that you have
to call it as Box::into_raw_with_allocator(b)
instead of b.into_raw_with_allocator()
. This
is so that there is no conflict with a method on the inner type.
§Examples
Converting the raw pointer back into a Box
with Box::from_raw_in
for automatic cleanup:
use stdx::alloc::Global;
use commonlibsse_ng::re::TESBox::TESBox;
let x = TESBox::new_in(String::from("Hello"), Global);
let (ptr, alloc) = TESBox::into_raw_with_allocator(x);
let x = unsafe { TESBox::from_raw_in(ptr, alloc) };
Manual cleanup by explicitly running the destructor and deallocating the memory:
use std::alloc::Layout;
use std::ptr::{self, NonNull};
use stdx::alloc::{Allocator, Global};
use commonlibsse_ng::re::TESBox::TESBox;
let x = TESBox::new_in(String::from("Hello"), Global);
let (ptr, alloc) = TESBox::into_raw_with_allocator(x);
unsafe {
ptr::drop_in_place(ptr);
let non_null = NonNull::new_unchecked(ptr);
alloc.deallocate(non_null.cast(), Layout::new::<String>());
}
Sourcepub fn into_non_null_with_allocator(b: Self) -> (NonNull<T>, A)
pub fn into_non_null_with_allocator(b: Self) -> (NonNull<T>, A)
Consumes the TESBox
, returning a wrapped NonNull
pointer and the allocator.
The pointer will be properly aligned.
After calling this function, the caller is responsible for the
memory previously managed by the Box
. In particular, the
caller should properly destroy T
and release the memory, taking
into account the memory layout used by TESBox
. The easiest way to
do this is to convert the NonNull
pointer back into a Box
with the
TESBox::from_non_null_in
function, allowing the Box
destructor to
perform the cleanup.
Note: this is an associated function, which means that you have
to call it as Box::into_non_null_with_allocator(b)
instead of
b.into_non_null_with_allocator()
. This is so that there is no
conflict with a method on the inner type.
§Examples
Converting the NonNull
pointer back into a Box
with
Box::from_non_null_in
for automatic cleanup:
use stdx::alloc::Global;
let x = TESBox::new_in(String::from("Hello"), Global);
let (non_null, alloc) = TESBox::into_non_null_with_allocator(x);
let x = unsafe { TESBox::from_non_null_in(non_null, alloc) };
Manual cleanup by explicitly running the destructor and deallocating the memory:
use stdx::alloc::{Allocator, Global};
use std::alloc::Layout;
use commonlibsse_ng::re::TESBox::TESBox;
let x = TESBox::new_in(String::from("Hello"), Global);
let (non_null, alloc) = TESBox::into_non_null_with_allocator(x);
unsafe {
non_null.drop_in_place();
alloc.deallocate(non_null.cast::<u8>(), Layout::new::<String>());
}
Sourcepub fn as_mut_ptr(b: &mut Self) -> *mut T
pub fn as_mut_ptr(b: &mut Self) -> *mut T
Returns a raw mutable pointer to the Box
’s contents.
The caller must ensure that the Box
outlives the pointer this
function returns, or else it will end up dangling.
This method guarantees that for the purpose of the aliasing model, this method
does not materialize a reference to the underlying memory, and thus the returned pointer
will remain valid when mixed with other calls to as_ptr
and as_mut_ptr
.
Note that calling other methods that materialize references to the memory
may still invalidate this pointer.
See the example below for how this guarantee can be used.
§Examples
Due to the aliasing guarantee, the following code is legal:
use commonlibsse_ng::re::TESBox::TESBox;
unsafe {
let mut b = TESBox::new(0);
let ptr1 = TESBox::as_mut_ptr(&mut b);
ptr1.write(1);
let ptr2 = TESBox::as_mut_ptr(&mut b);
ptr2.write(2);
// Notably, the write to `ptr2` did *not* invalidate `ptr1`:
ptr1.write(3);
}
Sourcepub fn as_ptr(b: &Self) -> *const T
pub fn as_ptr(b: &Self) -> *const T
Returns a raw pointer to the Box
’s contents.
The caller must ensure that the Box
outlives the pointer this
function returns, or else it will end up dangling.
The caller must also ensure that the memory the pointer (non-transitively) points to
is never written to (except inside an UnsafeCell
) using this pointer or any pointer
derived from it. If you need to mutate the contents of the Box
, use as_mut_ptr
.
This method guarantees that for the purpose of the aliasing model, this method
does not materialize a reference to the underlying memory, and thus the returned pointer
will remain valid when mixed with other calls to as_ptr
and as_mut_ptr
.
Note that calling other methods that materialize mutable references to the memory,
as well as writing to this memory, may still invalidate this pointer.
See the example below for how this guarantee can be used.
§Examples
Due to the aliasing guarantee, the following code is legal:
unsafe {
let mut v = TESBox::new(0);
let ptr1 = TESBox::as_ptr(&v);
let ptr2 = TESBox::as_mut_ptr(&mut v);
let _val = ptr2.read();
// No write to this memory has happened yet, so `ptr1` is still valid.
let _val = ptr1.read();
// However, once we do a write...
ptr2.write(1);
// ... `ptr1` is no longer valid.
// This would be UB: let _val = ptr1.read();
}
Sourcepub const fn allocator(b: &Self) -> &A
pub const fn allocator(b: &Self) -> &A
Returns a reference to the underlying allocator.
Note: this is an associated function, which means that you have
to call it as Box::allocator(&b)
instead of b.allocator()
. This
is so that there is no conflict with a method on the inner type.
Sourcepub fn leak<'a>(b: Self) -> &'a mut Twhere
A: 'a,
pub fn leak<'a>(b: Self) -> &'a mut Twhere
A: 'a,
Consumes and leaks the Box
, returning a mutable reference,
&'a mut T
.
Note that the type T
must outlive the chosen lifetime 'a
. If the type
has only static references, or none at all, then this may be chosen to be
'static
.
This function is mainly useful for data that lives for the remainder of
the program’s life. Dropping the returned reference will cause a memory
leak. If this is not acceptable, the reference should first be wrapped
with the Box::from_raw
function producing a Box
. This Box
can
then be dropped which will properly destroy T
and release the
allocated memory.
Note: this is an associated function, which means that you have
to call it as Box::leak(b)
instead of b.leak()
. This
is so that there is no conflict with a method on the inner type.
§Examples
Simple usage:
let x = TESBox::new(41);
let static_ref: &'static mut usize = TESBox::leak(x);
*static_ref += 1;
assert_eq!(*static_ref, 42);
Unsized data:
// let x = vec![1, 2, 3].into_boxed_slice();
// let static_ref = TESBox::leak(x);
// static_ref[0] = 4;
// assert_eq!(*static_ref, [4, 2, 3]);
// # drop(unsafe { TESBox::from_raw(static_ref) });
Sourcepub const fn into_pin(boxed: Self) -> Pin<Self>where
A: 'static,
pub const fn into_pin(boxed: Self) -> Pin<Self>where
A: 'static,
Converts a TESBox<T>
into a Pin<TESBox<T>>
. If T
does not implement Unpin
, then
*boxed
will be pinned in memory and unable to be moved.
This conversion does not allocate on the heap and happens in place.
This is also available via From
.
Constructing and pinning a TESBox
with TESBox::into_pin(TESBox::new(x))
can also be written more concisely using [TESBox::pin](x)
.
This into_pin
method is useful if you already have a TESBox<T>
, or you are
constructing a (pinned) TESBox
in a different way than with TESBox::new
.
§Notes
It’s not recommended that crates add an impl like From<TESBox<T>> for Pin<T>
,
as it’ll introduce an ambiguity when calling Pin::from
.
A demonstration of such a poor impl is shown below.
struct Foo; // A type defined in this crate.
impl From<TESBox<()>> for Pin<Foo> {
fn from(_: TESBox<()>) -> Pin<Foo> {
Pin::new(Foo)
}
}
let foo = TESBox::new(());
let bar = Pin::from(foo);
Trait Implementations§
Source§impl<T: ?Sized, A: Allocator> BorrowMut<T> for TESBox<T, A>
impl<T: ?Sized, A: Allocator> BorrowMut<T> for TESBox<T, A>
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T: Clone, A: Allocator + Clone> Clone for TESBox<[T], A>
impl<T: Clone, A: Allocator + Clone> Clone for TESBox<[T], A>
Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Copies source
’s contents into self
without creating a new allocation,
so long as the two are of the same length.
§Examples
let x = TESBox::new([5, 6, 7]);
let mut y = TESBox::new([8, 9, 10]);
let yp: *const [i32] = &*y;
y.clone_from(&x);
// The value is the same
assert_eq!(x, y);
// And no allocation occurred
assert_eq!(yp, &*y);
Source§impl<T: Clone, A: Allocator + Clone> Clone for TESBox<T, A>
impl<T: Clone, A: Allocator + Clone> Clone for TESBox<T, A>
Source§fn clone(&self) -> Self
fn clone(&self) -> Self
Returns a new box with a clone()
of this box’s contents.
§Examples
let x = TESBox::new(5);
let y = x.clone();
// The value is the same
assert_eq!(x, y);
// But they are unique objects
assert_ne!(&*x as *const i32, &*y as *const i32);
Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Copies source
’s contents into self
without creating a new allocation.
§Examples
let x = TESBox::new(5);
let mut y = TESBox::new(10);
let yp: *const i32 = &*y;
y.clone_from(&x);
// The value is the same
assert_eq!(x, y);
// And no allocation occurred
assert_eq!(yp, &*y);
Source§impl<E: Error> Error for TESBox<E>
impl<E: Error> Error for TESBox<E>
Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§fn cause(&self) -> Option<&dyn Error>
fn cause(&self) -> Option<&dyn Error>
Source§impl<T: ?Sized + Hasher, A: Allocator> Hasher for TESBox<T, A>
impl<T: ?Sized + Hasher, A: Allocator> Hasher for TESBox<T, A>
Source§fn write_u128(&mut self, i: u128)
fn write_u128(&mut self, i: u128)
u128
into this hasher.Source§fn write_usize(&mut self, i: usize)
fn write_usize(&mut self, i: usize)
usize
into this hasher.Source§fn write_i128(&mut self, i: i128)
fn write_i128(&mut self, i: i128)
i128
into this hasher.Source§fn write_isize(&mut self, i: isize)
fn write_isize(&mut self, i: isize)
isize
into this hasher.Source§fn write_length_prefix(&mut self, len: usize)
fn write_length_prefix(&mut self, len: usize)
hasher_prefixfree_extras
)