pub struct Box<T, A =Global>(/* private fields */)where A:Allocator, T: ?Sized;Expand description
A pointer type that uniquely owns a heap allocation of typeT.
See themodule-level documentation for more.
Implementations§
Source§impl<A>Box<dynAny, A>where A:Allocator,
impl<A>Box<dynAny, A>where A:Allocator,
1.0.0 ·Sourcepub fndowncast<T>(self) ->Result<Box<T, A>,Box<dynAny, A>>where T:Any,
pub fndowncast<T>(self) ->Result<Box<T, A>,Box<dynAny, A>>where T:Any,
Attempts to downcast the box to a concrete type.
§Examples
Sourcepub unsafe fndowncast_unchecked<T>(self) ->Box<T, A>where T:Any,
🔬This is a nightly-only experimental API. (downcast_unchecked #90850)
pub unsafe fndowncast_unchecked<T>(self) ->Box<T, A>where T:Any,
downcast_unchecked #90850)Downcasts the box to a concrete type.
For a safe alternative seedowncast.
§Examples
#![feature(downcast_unchecked)]usestd::any::Any;letx: Box<dynAny> = Box::new(1_usize);unsafe{assert_eq!(*x.downcast_unchecked::<usize>(),1);}§Safety
The contained value must be of typeT. Calling this methodwith the incorrect type isundefined behavior.
Source§impl<A>Box<dynAny +Send, A>where A:Allocator,
impl<A>Box<dynAny +Send, A>where A:Allocator,
1.0.0 ·Sourcepub fndowncast<T>(self) ->Result<Box<T, A>,Box<dynAny +Send, A>>where T:Any,
pub fndowncast<T>(self) ->Result<Box<T, A>,Box<dynAny +Send, A>>where T:Any,
Attempts to downcast the box to a concrete type.
§Examples
Sourcepub unsafe fndowncast_unchecked<T>(self) ->Box<T, A>where T:Any,
🔬This is a nightly-only experimental API. (downcast_unchecked #90850)
pub unsafe fndowncast_unchecked<T>(self) ->Box<T, A>where T:Any,
downcast_unchecked #90850)Downcasts the box to a concrete type.
For a safe alternative seedowncast.
§Examples
#![feature(downcast_unchecked)]usestd::any::Any;letx: Box<dynAny + Send> = Box::new(1_usize);unsafe{assert_eq!(*x.downcast_unchecked::<usize>(),1);}§Safety
The contained value must be of typeT. Calling this methodwith the incorrect type isundefined behavior.
Source§impl<A>Box<dynAny +Send +Sync, A>where A:Allocator,
impl<A>Box<dynAny +Send +Sync, A>where A:Allocator,
1.51.0 ·Sourcepub fndowncast<T>(self) ->Result<Box<T, A>,Box<dynAny +Send +Sync, A>>where T:Any,
pub fndowncast<T>(self) ->Result<Box<T, A>,Box<dynAny +Send +Sync, A>>where T:Any,
Attempts to downcast the box to a concrete type.
§Examples
Sourcepub unsafe fndowncast_unchecked<T>(self) ->Box<T, A>where T:Any,
🔬This is a nightly-only experimental API. (downcast_unchecked #90850)
pub unsafe fndowncast_unchecked<T>(self) ->Box<T, A>where T:Any,
downcast_unchecked #90850)Downcasts the box to a concrete type.
For a safe alternative seedowncast.
§Examples
#![feature(downcast_unchecked)]usestd::any::Any;letx: Box<dynAny + Send + Sync> = Box::new(1_usize);unsafe{assert_eq!(*x.downcast_unchecked::<usize>(),1);}§Safety
The contained value must be of typeT. Calling this methodwith the incorrect type isundefined behavior.
Source§impl<T>Box<T>
impl<T>Box<T>
1.0.0 ·Sourcepub fnnew(x: T) ->Box<T>
pub fnnew(x: T) ->Box<T>
Allocates memory on the heap and then placesx into it.
This doesn’t actually allocate ifT is zero-sized.
§Examples
1.82.0 ·Sourcepub fnnew_uninit() ->Box<MaybeUninit<T>>
pub fnnew_uninit() ->Box<MaybeUninit<T>>
Constructs a new box with uninitialized contents.
§Examples
1.92.0 ·Sourcepub fnnew_zeroed() ->Box<MaybeUninit<T>>
pub fnnew_zeroed() ->Box<MaybeUninit<T>>
Constructs a newBox with uninitialized contents, with the memorybeing filled with0 bytes.
SeeMaybeUninit::zeroed for examples of correct and incorrect usageof this method.
§Examples
1.33.0 ·Sourcepub fnpin(x: T) ->Pin<Box<T>>
pub fnpin(x: T) ->Pin<Box<T>>
Constructs a newPin<Box<T>>. IfT does not implementUnpin, thenx will be pinned in memory and unable to be moved.
Constructing and pinning of theBox can also be done in two steps:Box::pin(x)does the same asBox::into_pin(Box::new(x)). Consider usinginto_pin if you already have aBox<T>, or if you want toconstruct a (pinned)Box in a different way than withBox::new.
Sourcepub fntry_new(x: T) ->Result<Box<T>,AllocError>
🔬This is a nightly-only experimental API. (allocator_api #32838)
pub fntry_new(x: T) ->Result<Box<T>,AllocError>
allocator_api #32838)Allocates memory on the heap then placesx into it,returning an error if the allocation fails
This doesn’t actually allocate ifT is zero-sized.
§Examples
Sourcepub fntry_new_uninit() ->Result<Box<MaybeUninit<T>>,AllocError>
🔬This is a nightly-only experimental API. (allocator_api #32838)
pub fntry_new_uninit() ->Result<Box<MaybeUninit<T>>,AllocError>
allocator_api #32838)Constructs a new box with uninitialized contents on the heap,returning an error if the allocation fails
§Examples
Sourcepub fntry_new_zeroed() ->Result<Box<MaybeUninit<T>>,AllocError>
🔬This is a nightly-only experimental API. (allocator_api #32838)
pub fntry_new_zeroed() ->Result<Box<MaybeUninit<T>>,AllocError>
allocator_api #32838)Constructs a newBox with uninitialized contents, with the memorybeing filled with0 bytes on the heap
SeeMaybeUninit::zeroed for examples of correct and incorrect usageof this method.
§Examples
Sourcepub fnmap<U>(this:Box<T>, f: implFnOnce(T) -> U) ->Box<U>
🔬This is a nightly-only experimental API. (smart_pointer_try_map #144419)
pub fnmap<U>(this:Box<T>, f: implFnOnce(T) -> U) ->Box<U>
smart_pointer_try_map #144419)Maps the value in a box, reusing the allocation if possible.
f is called on the value in the box, and the result is returned, also boxed.
Note: this is an associated function, which means that you haveto call it asBox::map(b, f) instead ofb.map(f). Thisis so that there is no conflict with a method on the inner type.
§Examples
Sourcepub fntry_map<R>( this:Box<T>, f: implFnOnce(T) -> R,) -> <<R asTry>::Residual asResidual<Box<<R asTry>::Output>>>::TryType
🔬This is a nightly-only experimental API. (smart_pointer_try_map #144419)
pub fntry_map<R>( this:Box<T>, f: implFnOnce(T) -> R,) -> <<R asTry>::Residual asResidual<Box<<R asTry>::Output>>>::TryType
smart_pointer_try_map #144419)Attempts to map the value in a box, reusing the allocation if possible.
f is called on the value in the box, and if the operation succeeds, the result isreturned, also boxed.
Note: this is an associated function, which means that you haveto call it asBox::try_map(b, f) instead ofb.try_map(f). Thisis so that there is no conflict with a method on the inner type.
§Examples
Source§impl<T, A>Box<T, A>where A:Allocator,
impl<T, A>Box<T, A>where A:Allocator,
Sourcepub fnnew_in(x: T, alloc: A) ->Box<T, A>where A:Allocator,
🔬This is a nightly-only experimental API. (allocator_api #32838)
pub fnnew_in(x: T, alloc: A) ->Box<T, A>where A:Allocator,
allocator_api #32838)Allocates memory in the given allocator then placesx into it.
This doesn’t actually allocate ifT is zero-sized.
§Examples
Sourcepub fntry_new_in(x: T, alloc: A) ->Result<Box<T, A>,AllocError>where A:Allocator,
🔬This is a nightly-only experimental API. (allocator_api #32838)
pub fntry_new_in(x: T, alloc: A) ->Result<Box<T, A>,AllocError>where A:Allocator,
allocator_api #32838)Allocates memory in the given allocator then placesx into it,returning an error if the allocation fails
This doesn’t actually allocate ifT is zero-sized.
§Examples
Sourcepub fnnew_uninit_in(alloc: A) ->Box<MaybeUninit<T>, A>where A:Allocator,
🔬This is a nightly-only experimental API. (allocator_api #32838)
pub fnnew_uninit_in(alloc: A) ->Box<MaybeUninit<T>, A>where A:Allocator,
allocator_api #32838)Constructs a new box with uninitialized contents in the provided allocator.
§Examples
Sourcepub fntry_new_uninit_in(alloc: A) ->Result<Box<MaybeUninit<T>, A>,AllocError>where A:Allocator,
🔬This is a nightly-only experimental API. (allocator_api #32838)
pub fntry_new_uninit_in(alloc: A) ->Result<Box<MaybeUninit<T>, A>,AllocError>where A:Allocator,
allocator_api #32838)Constructs a new box with uninitialized contents in the provided allocator,returning an error if the allocation fails
§Examples
Sourcepub fnnew_zeroed_in(alloc: A) ->Box<MaybeUninit<T>, A>where A:Allocator,
🔬This is a nightly-only experimental API. (allocator_api #32838)
pub fnnew_zeroed_in(alloc: A) ->Box<MaybeUninit<T>, A>where A:Allocator,
allocator_api #32838)Constructs a newBox with uninitialized contents, with the memorybeing filled with0 bytes in the provided allocator.
SeeMaybeUninit::zeroed for examples of correct and incorrect usageof this method.
§Examples
Sourcepub fntry_new_zeroed_in(alloc: A) ->Result<Box<MaybeUninit<T>, A>,AllocError>where A:Allocator,
🔬This is a nightly-only experimental API. (allocator_api #32838)
pub fntry_new_zeroed_in(alloc: A) ->Result<Box<MaybeUninit<T>, A>,AllocError>where A:Allocator,
allocator_api #32838)Constructs a newBox with uninitialized contents, with the memorybeing filled with0 bytes in the provided allocator,returning an error if the allocation fails,
SeeMaybeUninit::zeroed for examples of correct and incorrect usageof this method.
§Examples
Sourcepub fnpin_in(x: T, alloc: A) ->Pin<Box<T, A>>where A: 'static +Allocator,
🔬This is a nightly-only experimental API. (allocator_api #32838)
pub fnpin_in(x: T, alloc: A) ->Pin<Box<T, A>>where A: 'static +Allocator,
allocator_api #32838)Constructs a newPin<Box<T, A>>. IfT does not implementUnpin, thenx will be pinned in memory and unable to be moved.
Constructing and pinning of theBox can also be done in two steps:Box::pin_in(x, alloc)does the same asBox::into_pin(Box::new_in(x, alloc)). Consider usinginto_pin if you already have aBox<T, A>, or if you want toconstruct a (pinned)Box in a different way than withBox::new_in.
Sourcepub fninto_boxed_slice(boxed:Box<T, A>) ->Box<[T], A>
🔬This is a nightly-only experimental API. (box_into_boxed_slice #71582)
pub fninto_boxed_slice(boxed:Box<T, A>) ->Box<[T], A>
box_into_boxed_slice #71582)Converts aBox<T> into aBox<[T]>
This conversion does not allocate on the heap and happens in place.
Sourcepub fninto_inner(boxed:Box<T, A>) -> T
🔬This is a nightly-only experimental API. (box_into_inner #80437)
pub fninto_inner(boxed:Box<T, A>) -> T
box_into_inner #80437)Consumes theBox, returning the wrapped value.
§Examples
Sourcepub fntake(boxed:Box<T, A>) -> (T,Box<MaybeUninit<T>, A>)
🔬This is a nightly-only experimental API. (box_take #147212)
pub fntake(boxed:Box<T, A>) -> (T,Box<MaybeUninit<T>, A>)
box_take #147212)Source§impl<T>Box<T>where T:CloneToUninit + ?Sized,
impl<T>Box<T>where T:CloneToUninit + ?Sized,
Sourcepub fnclone_from_ref(src:&T) ->Box<T>
🔬This is a nightly-only experimental API. (clone_from_ref #149075)
pub fnclone_from_ref(src:&T) ->Box<T>
clone_from_ref #149075)Allocates memory on the heap then clonessrc into it.
This doesn’t actually allocate ifsrc is zero-sized.
§Examples
Sourcepub fntry_clone_from_ref(src:&T) ->Result<Box<T>,AllocError>
🔬This is a nightly-only experimental API. (clone_from_ref #149075)
pub fntry_clone_from_ref(src:&T) ->Result<Box<T>,AllocError>
clone_from_ref #149075)Allocates memory on the heap then clonessrc into it, returning an error if allocation fails.
This doesn’t actually allocate ifsrc is zero-sized.
§Examples
Source§impl<T, A>Box<T, A>
impl<T, A>Box<T, A>
Sourcepub fnclone_from_ref_in(src:&T, alloc: A) ->Box<T, A>
🔬This is a nightly-only experimental API. (clone_from_ref #149075)
pub fnclone_from_ref_in(src:&T, alloc: A) ->Box<T, A>
clone_from_ref #149075)Allocates memory in the given allocator then clonessrc into it.
This doesn’t actually allocate ifsrc is zero-sized.
§Examples
Sourcepub fntry_clone_from_ref_in(src:&T, alloc: A) ->Result<Box<T, A>,AllocError>
🔬This is a nightly-only experimental API. (clone_from_ref #149075)
pub fntry_clone_from_ref_in(src:&T, alloc: A) ->Result<Box<T, A>,AllocError>
clone_from_ref #149075)Allocates memory in the given allocator then clonessrc into it, returning an error if allocation fails.
This doesn’t actually allocate ifsrc is zero-sized.
§Examples
Source§impl<T>Box<[T]>
impl<T>Box<[T]>
1.82.0 ·Sourcepub fnnew_uninit_slice(len:usize) ->Box<[MaybeUninit<T>]>
pub fnnew_uninit_slice(len:usize) ->Box<[MaybeUninit<T>]>
Constructs a new boxed slice with uninitialized contents.
§Examples
1.92.0 ·Sourcepub fnnew_zeroed_slice(len:usize) ->Box<[MaybeUninit<T>]>
pub fnnew_zeroed_slice(len:usize) ->Box<[MaybeUninit<T>]>
Constructs a new boxed slice with uninitialized contents, with the memorybeing filled with0 bytes.
SeeMaybeUninit::zeroed for examples of correct and incorrect usageof this method.
§Examples
Sourcepub fntry_new_uninit_slice( len:usize,) ->Result<Box<[MaybeUninit<T>]>,AllocError>
🔬This is a nightly-only experimental API. (allocator_api #32838)
pub fntry_new_uninit_slice( len:usize,) ->Result<Box<[MaybeUninit<T>]>,AllocError>
allocator_api #32838)Constructs a new boxed slice with uninitialized contents. Returns an error ifthe allocation fails.
§Examples
Sourcepub fntry_new_zeroed_slice( len:usize,) ->Result<Box<[MaybeUninit<T>]>,AllocError>
🔬This is a nightly-only experimental API. (allocator_api #32838)
pub fntry_new_zeroed_slice( len:usize,) ->Result<Box<[MaybeUninit<T>]>,AllocError>
allocator_api #32838)Constructs a new boxed slice with uninitialized contents, with the memorybeing filled with0 bytes. Returns an error if the allocation fails.
SeeMaybeUninit::zeroed for examples of correct and incorrect usageof this method.
§Examples
Sourcepub fninto_array<const N:usize>(self) ->Option<Box<[T; N]>>
🔬This is a nightly-only experimental API. (alloc_slice_into_array #148082)
pub fninto_array<const N:usize>(self) ->Option<Box<[T; N]>>
alloc_slice_into_array #148082)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.
IfN is not exactly equal to the length ofself, then this method returnsNone.
Source§impl<T, A>Box<[T], A>where A:Allocator,
impl<T, A>Box<[T], A>where A:Allocator,
Sourcepub fnnew_uninit_slice_in(len:usize, alloc: A) ->Box<[MaybeUninit<T>], A>
🔬This is a nightly-only experimental API. (allocator_api #32838)
pub fnnew_uninit_slice_in(len:usize, alloc: A) ->Box<[MaybeUninit<T>], A>
allocator_api #32838)Constructs a new boxed slice with uninitialized contents in the provided allocator.
§Examples
Sourcepub fnnew_zeroed_slice_in(len:usize, alloc: A) ->Box<[MaybeUninit<T>], A>
🔬This is a nightly-only experimental API. (allocator_api #32838)
pub fnnew_zeroed_slice_in(len:usize, alloc: A) ->Box<[MaybeUninit<T>], A>
allocator_api #32838)Constructs a new boxed slice with uninitialized contents in the provided allocator,with the memory being filled with0 bytes.
SeeMaybeUninit::zeroed for examples of correct and incorrect usageof this method.
§Examples
Sourcepub fntry_new_uninit_slice_in( len:usize, alloc: A,) ->Result<Box<[MaybeUninit<T>], A>,AllocError>
🔬This is a nightly-only experimental API. (allocator_api #32838)
pub fntry_new_uninit_slice_in( len:usize, alloc: A,) ->Result<Box<[MaybeUninit<T>], A>,AllocError>
allocator_api #32838)Constructs a new boxed slice with uninitialized contents in the provided allocator. Returns an error ifthe allocation fails.
§Examples
Sourcepub fntry_new_zeroed_slice_in( len:usize, alloc: A,) ->Result<Box<[MaybeUninit<T>], A>,AllocError>
🔬This is a nightly-only experimental API. (allocator_api #32838)
pub fntry_new_zeroed_slice_in( len:usize, alloc: A,) ->Result<Box<[MaybeUninit<T>], A>,AllocError>
allocator_api #32838)Constructs a new boxed slice with uninitialized contents in the provided allocator, with the memorybeing filled with0 bytes. Returns an error if the allocation fails.
SeeMaybeUninit::zeroed for examples of correct and incorrect usageof this method.
§Examples
Source§impl<T, A>Box<MaybeUninit<T>, A>where A:Allocator,
impl<T, A>Box<MaybeUninit<T>, A>where A:Allocator,
1.82.0 ·Sourcepub unsafe fnassume_init(self) ->Box<T, A>
pub unsafe fnassume_init(self) ->Box<T, A>
Converts toBox<T, A>.
§Safety
As withMaybeUninit::assume_init,it is up to the caller to guarantee that the valuereally is in an initialized state.Calling this when the content is not yet fully initializedcauses immediate undefined behavior.
§Examples
1.87.0 ·Sourcepub fnwrite(boxed:Box<MaybeUninit<T>, A>, value: T) ->Box<T, A>
pub fnwrite(boxed:Box<MaybeUninit<T>, A>, value: T) ->Box<T, A>
Writes the value and converts toBox<T, A>.
This method converts the box similarly toBox::assume_init butwritesvalue into it before conversion thus guaranteeing safety.In some scenarios use of this method may improve performance becausethe compiler may be able to optimize copying from stack.
§Examples
letbig_box = Box::<[usize;1024]>::new_uninit();letmutarray = [0;1024];for(i, place)inarray.iter_mut().enumerate() {*place = i;}// The optimizer may be able to elide this copy, so previous code writes// to heap directly.letbig_box = Box::write(big_box, array);for(i, x)inbig_box.iter().enumerate() {assert_eq!(*x, i);}Source§impl<T, A>Box<[MaybeUninit<T>], A>where A:Allocator,
impl<T, A>Box<[MaybeUninit<T>], A>where A:Allocator,
1.82.0 ·Sourcepub unsafe fnassume_init(self) ->Box<[T], A>
pub unsafe fnassume_init(self) ->Box<[T], A>
Converts toBox<[T], A>.
§Safety
As withMaybeUninit::assume_init,it is up to the caller to guarantee that the valuesreally are in an initialized state.Calling this when the content is not yet fully initializedcauses immediate undefined behavior.
§Examples
Source§impl<T>Box<T>where T: ?Sized,
impl<T>Box<T>where T: ?Sized,
1.4.0 ·Sourcepub unsafe fnfrom_raw(raw:*mut T) ->Box<T>
pub unsafe fnfrom_raw(raw:*mut T) ->Box<T>
Constructs a box from a raw pointer.
After calling this function, the raw pointer is owned by theresultingBox. Specifically, theBox destructor will callthe destructor ofT and free the allocated memory. For thisto be safe, the memory must have been allocated in accordancewith thememory layout used byBox .
§Safety
This function is unsafe because improper use may lead tomemory problems. For example, a double-free may occur if thefunction 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 thememory layout section.
§Examples
Recreate aBox which was previously converted to a raw pointerusingBox::into_raw:
Manually create aBox from scratch by using the global allocator:
usestd::alloc::{alloc, Layout};unsafe{letptr = alloc(Layout::new::<i32>())as*muti32;// 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);letx = Box::from_raw(ptr);}Sourcepub unsafe fnfrom_non_null(ptr:NonNull<T>) ->Box<T>
🔬This is a nightly-only experimental API. (box_vec_non_null #130364)
pub unsafe fnfrom_non_null(ptr:NonNull<T>) ->Box<T>
box_vec_non_null #130364)Constructs a box from aNonNull pointer.
After calling this function, theNonNull pointer is owned bythe resultingBox. Specifically, theBox destructor will callthe destructor ofT and free the allocated memory. For thisto be safe, the memory must have been allocated in accordancewith thememory layout used byBox .
§Safety
This function is unsafe because improper use may lead tomemory problems. For example, a double-free may occur if thefunction is called twice on the sameNonNull pointer.
The non-null pointer must point to a block of memory allocated by the global allocator.
The safety conditions are described in thememory layout section.
§Examples
Recreate aBox which was previously converted to aNonNullpointer usingBox::into_non_null:
#![feature(box_vec_non_null)]letx = Box::new(5);letnon_null = Box::into_non_null(x);letx =unsafe{ Box::from_non_null(non_null) };Manually create aBox from scratch by using the global allocator:
#![feature(box_vec_non_null)]usestd::alloc::{alloc, Layout};usestd::ptr::NonNull;unsafe{letnon_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);letx = Box::from_non_null(non_null);}1.4.0 ·Sourcepub fninto_raw(b:Box<T>) ->*mut T
pub fninto_raw(b:Box<T>) ->*mut T
Consumes theBox, returning a wrapped raw pointer.
The pointer will be properly aligned and non-null.
After calling this function, the caller is responsible for thememory previously managed by theBox. In particular, thecaller should properly destroyT and release the memory, takinginto account thememory layout used byBox. The easiest way todo this is to convert the raw pointer back into aBox with theBox::from_raw function, allowing theBox destructor to performthe cleanup.
Note: this is an associated function, which means that you haveto call it asBox::into_raw(b) instead ofb.into_raw(). Thisis so that there is no conflict with a method on the inner type.
§Examples
Converting the raw pointer back into aBox withBox::from_rawfor automatic cleanup:
letx = Box::new(String::from("Hello"));letptr = Box::into_raw(x);letx =unsafe{ Box::from_raw(ptr) };Manual cleanup by explicitly running the destructor and deallocatingthe memory:
usestd::alloc::{dealloc, Layout};usestd::ptr;letx = Box::new(String::from("Hello"));letptr = Box::into_raw(x);unsafe{ ptr::drop_in_place(ptr); dealloc(ptras*mutu8, Layout::new::<String>());}Note: This is equivalent to the following:
Sourcepub fninto_non_null(b:Box<T>) ->NonNull<T>
🔬This is a nightly-only experimental API. (box_vec_non_null #130364)
pub fninto_non_null(b:Box<T>) ->NonNull<T>
box_vec_non_null #130364)Consumes theBox, returning a wrappedNonNull pointer.
The pointer will be properly aligned.
After calling this function, the caller is responsible for thememory previously managed by theBox. In particular, thecaller should properly destroyT and release the memory, takinginto account thememory layout used byBox. The easiest way todo this is to convert theNonNull pointer back into aBox with theBox::from_non_null function, allowing theBox destructor toperform the cleanup.
Note: this is an associated function, which means that you haveto call it asBox::into_non_null(b) instead ofb.into_non_null().This is so that there is no conflict with a method on the inner type.
§Examples
Converting theNonNull pointer back into aBox withBox::from_non_nullfor automatic cleanup:
#![feature(box_vec_non_null)]letx = Box::new(String::from("Hello"));letnon_null = Box::into_non_null(x);letx =unsafe{ Box::from_non_null(non_null) };Manual cleanup by explicitly running the destructor and deallocatingthe memory:
#![feature(box_vec_non_null)]usestd::alloc::{dealloc, Layout};letx = Box::new(String::from("Hello"));letnon_null = Box::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:
Source§impl<T, A>Box<T, A>
impl<T, A>Box<T, A>
Sourcepub unsafe fnfrom_raw_in(raw:*mut T, alloc: A) ->Box<T, A>
🔬This is a nightly-only experimental API. (allocator_api #32838)
pub unsafe fnfrom_raw_in(raw:*mut T, alloc: A) ->Box<T, A>
allocator_api #32838)Constructs a box from a raw pointer in the given allocator.
After calling this function, the raw pointer is owned by theresultingBox. Specifically, theBox destructor will callthe destructor ofT and free the allocated memory. For thisto be safe, the memory must have been allocated in accordancewith thememory layout used byBox .
§Safety
This function is unsafe because improper use may lead tomemory problems. For example, a double-free may occur if thefunction is called twice on the same raw pointer.
The raw pointer must point to a block of memory allocated byalloc.
§Examples
Recreate aBox which was previously converted to a raw pointerusingBox::into_raw_with_allocator:
#![feature(allocator_api)]usestd::alloc::System;letx = Box::new_in(5, System);let(ptr, alloc) = Box::into_raw_with_allocator(x);letx =unsafe{ Box::from_raw_in(ptr, alloc) };Manually create aBox from scratch by using the system allocator:
#![feature(allocator_api, slice_ptr_get)]usestd::alloc::{Allocator, Layout, System};unsafe{letptr = System.allocate(Layout::new::<i32>())?.as_mut_ptr()as*muti32;// 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);letx = Box::from_raw_in(ptr, System);}Sourcepub unsafe fnfrom_non_null_in(raw:NonNull<T>, alloc: A) ->Box<T, A>
🔬This is a nightly-only experimental API. (allocator_api #32838)
pub unsafe fnfrom_non_null_in(raw:NonNull<T>, alloc: A) ->Box<T, A>
allocator_api #32838)Constructs a box from aNonNull pointer in the given allocator.
After calling this function, theNonNull pointer is owned bythe resultingBox. Specifically, theBox destructor will callthe destructor ofT and free the allocated memory. For thisto be safe, the memory must have been allocated in accordancewith thememory layout used byBox .
§Safety
This function is unsafe because improper use may lead tomemory problems. For example, a double-free may occur if thefunction is called twice on the same raw pointer.
The non-null pointer must point to a block of memory allocated byalloc.
§Examples
Recreate aBox which was previously converted to aNonNull pointerusingBox::into_non_null_with_allocator:
#![feature(allocator_api, box_vec_non_null)]usestd::alloc::System;letx = Box::new_in(5, System);let(non_null, alloc) = Box::into_non_null_with_allocator(x);letx =unsafe{ Box::from_non_null_in(non_null, alloc) };Manually create aBox from scratch by using the system allocator:
#![feature(allocator_api, box_vec_non_null, slice_ptr_get)]usestd::alloc::{Allocator, Layout, System};unsafe{letnon_null = System.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);letx = Box::from_non_null_in(non_null, System);}Sourcepub fninto_raw_with_allocator(b:Box<T, A>) -> (*mut T, A)
🔬This is a nightly-only experimental API. (allocator_api #32838)
pub fninto_raw_with_allocator(b:Box<T, A>) -> (*mut T, A)
allocator_api #32838)Consumes theBox, 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 thememory previously managed by theBox. In particular, thecaller should properly destroyT and release the memory, takinginto account thememory layout used byBox. The easiest way todo this is to convert the raw pointer back into aBox with theBox::from_raw_in function, allowing theBox destructor to performthe cleanup.
Note: this is an associated function, which means that you haveto call it asBox::into_raw_with_allocator(b) instead ofb.into_raw_with_allocator(). Thisis so that there is no conflict with a method on the inner type.
§Examples
Converting the raw pointer back into aBox withBox::from_raw_infor automatic cleanup:
#![feature(allocator_api)]usestd::alloc::System;letx = Box::new_in(String::from("Hello"), System);let(ptr, alloc) = Box::into_raw_with_allocator(x);letx =unsafe{ Box::from_raw_in(ptr, alloc) };Manual cleanup by explicitly running the destructor and deallocatingthe memory:
#![feature(allocator_api)]usestd::alloc::{Allocator, Layout, System};usestd::ptr::{self, NonNull};letx = Box::new_in(String::from("Hello"), System);let(ptr, alloc) = Box::into_raw_with_allocator(x);unsafe{ ptr::drop_in_place(ptr);letnon_null = NonNull::new_unchecked(ptr); alloc.deallocate(non_null.cast(), Layout::new::<String>());}Sourcepub fninto_non_null_with_allocator(b:Box<T, A>) -> (NonNull<T>, A)
🔬This is a nightly-only experimental API. (allocator_api #32838)
pub fninto_non_null_with_allocator(b:Box<T, A>) -> (NonNull<T>, A)
allocator_api #32838)Consumes theBox, returning a wrappedNonNull pointer and the allocator.
The pointer will be properly aligned.
After calling this function, the caller is responsible for thememory previously managed by theBox. In particular, thecaller should properly destroyT and release the memory, takinginto account thememory layout used byBox. The easiest way todo this is to convert theNonNull pointer back into aBox with theBox::from_non_null_in function, allowing theBox destructor toperform the cleanup.
Note: this is an associated function, which means that you haveto call it asBox::into_non_null_with_allocator(b) instead ofb.into_non_null_with_allocator(). This is so that there is noconflict with a method on the inner type.
§Examples
Converting theNonNull pointer back into aBox withBox::from_non_null_in for automatic cleanup:
#![feature(allocator_api, box_vec_non_null)]usestd::alloc::System;letx = Box::new_in(String::from("Hello"), System);let(non_null, alloc) = Box::into_non_null_with_allocator(x);letx =unsafe{ Box::from_non_null_in(non_null, alloc) };Manual cleanup by explicitly running the destructor and deallocatingthe memory:
Sourcepub fnas_mut_ptr(b: &mutBox<T, A>) ->*mut T
🔬This is a nightly-only experimental API. (box_as_ptr #129090)
pub fnas_mut_ptr(b: &mutBox<T, A>) ->*mut T
box_as_ptr #129090)Returns a raw mutable pointer to theBox’s contents.
The caller must ensure that theBox outlives the pointer thisfunction returns, or else it will end up dangling.
This method guarantees that for the purpose of the aliasing model, this methoddoes not materialize a reference to the underlying memory, and thus the returned pointerwill remain valid when mixed with other calls toas_ptr andas_mut_ptr.Note that calling other methods that materialize references to the memorymay 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:
Sourcepub fnas_ptr(b: &Box<T, A>) ->*const T
🔬This is a nightly-only experimental API. (box_as_ptr #129090)
pub fnas_ptr(b: &Box<T, A>) ->*const T
box_as_ptr #129090)Returns a raw pointer to theBox’s contents.
The caller must ensure that theBox outlives the pointer thisfunction returns, or else it will end up dangling.
The caller must also ensure that the memory the pointer (non-transitively) points tois never written to (except inside anUnsafeCell) using this pointer or any pointerderived from it. If you need to mutate the contents of theBox, useas_mut_ptr.
This method guarantees that for the purpose of the aliasing model, this methoddoes not materialize a reference to the underlying memory, and thus the returned pointerwill remain valid when mixed with other calls toas_ptr andas_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:
#![feature(box_as_ptr)]unsafe{letmutv = Box::new(0);letptr1 = Box::as_ptr(&v);letptr2 = Box::as_mut_ptr(&mutv);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 fnallocator(b: &Box<T, A>) ->&A
🔬This is a nightly-only experimental API. (allocator_api #32838)
pub fnallocator(b: &Box<T, A>) ->&A
allocator_api #32838)Returns a reference to the underlying allocator.
Note: this is an associated function, which means that you haveto call it asBox::allocator(&b) instead ofb.allocator(). Thisis so that there is no conflict with a method on the inner type.
1.26.0 ·Sourcepub fnleak<'a>(b:Box<T, A>) ->&'a mut Twhere A: 'a,
pub fnleak<'a>(b:Box<T, A>) ->&'a mut Twhere A: 'a,
Consumes and leaks theBox, returning a mutable reference,&'a mut T.
Note that the typeT must outlive the chosen lifetime'a. If the typehas 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 ofthe program’s life. Dropping the returned reference will cause a memoryleak. If this is not acceptable, the reference should first be wrappedwith theBox::from_raw function producing aBox. ThisBox canthen be dropped which will properly destroyT and release theallocated memory.
Note: this is an associated function, which means that you haveto call it asBox::leak(b) instead ofb.leak(). Thisis so that there is no conflict with a method on the inner type.
§Examples
Simple usage:
letx = Box::new(41);letstatic_ref:&'staticmutusize = Box::leak(x);*static_ref +=1;assert_eq!(*static_ref,42);Unsized data:
1.63.0 ·Sourcepub fninto_pin(boxed:Box<T, A>) ->Pin<Box<T, A>>where A: 'static,
pub fninto_pin(boxed:Box<T, A>) ->Pin<Box<T, A>>where A: 'static,
Converts aBox<T> into aPin<Box<T>>. IfT does not implementUnpin, 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 viaFrom.
Constructing and pinning aBox withBox::into_pin(Box::new(x))can also be written more concisely usingBox::pin(x).Thisinto_pin method is useful if you already have aBox<T>, or you areconstructing a (pinned)Box in a different way than withBox::new.
§Notes
It’s not recommended that crates add an impl likeFrom<Box<T>> for Pin<T>,as it’ll introduce an ambiguity when callingPin::from.A demonstration of such a poor impl is shown below.
structFoo;// A type defined in this crate.implFrom<Box<()>>forPin<Foo> {fnfrom(_: Box<()>) -> Pin<Foo> { Pin::new(Foo) }}letfoo = Box::new(());letbar = Pin::from(foo);Trait Implementations§
Source§impl<T, A>Allocator forBox<T, A>
impl<T, A>Allocator forBox<T, A>
Source§fnallocate(&self, layout:Layout) ->Result<NonNull<[u8]>,AllocError>
fnallocate(&self, layout:Layout) ->Result<NonNull<[u8]>,AllocError>
allocator_api #32838)Source§fnallocate_zeroed(&self, layout:Layout) ->Result<NonNull<[u8]>,AllocError>
fnallocate_zeroed(&self, layout:Layout) ->Result<NonNull<[u8]>,AllocError>
allocator_api #32838)allocate, but also ensures that the returned memory is zero-initialized.Read moreSource§unsafe fndeallocate(&self, ptr:NonNull<u8>, layout:Layout)
unsafe fndeallocate(&self, ptr:NonNull<u8>, layout:Layout)
allocator_api #32838)ptr.Read moreSource§unsafe fngrow( &self, ptr:NonNull<u8>, old_layout:Layout, new_layout:Layout,) ->Result<NonNull<[u8]>,AllocError>
unsafe fngrow( &self, ptr:NonNull<u8>, old_layout:Layout, new_layout:Layout,) ->Result<NonNull<[u8]>,AllocError>
allocator_api #32838)Source§unsafe fngrow_zeroed( &self, ptr:NonNull<u8>, old_layout:Layout, new_layout:Layout,) ->Result<NonNull<[u8]>,AllocError>
unsafe fngrow_zeroed( &self, ptr:NonNull<u8>, old_layout:Layout, new_layout:Layout,) ->Result<NonNull<[u8]>,AllocError>
allocator_api #32838)grow, but also ensures that the new contents are set to zero before beingreturned.Read more1.64.0 ·Source§impl<T:AsFd + ?Sized>AsFd forBox<T>
Available onUnix or HermitCore ortarget_os=trusty or WASI ortarget_os=motor only.
impl<T:AsFd + ?Sized>AsFd forBox<T>
target_os=trusty or WASI ortarget_os=motor only.Source§fnas_fd(&self) ->BorrowedFd<'_>
fnas_fd(&self) ->BorrowedFd<'_>
1.71.0 ·Source§impl<T:AsHandle + ?Sized>AsHandle forBox<T>
Available onWindows only.
impl<T:AsHandle + ?Sized>AsHandle forBox<T>
Source§fnas_handle(&self) ->BorrowedHandle<'_>
fnas_handle(&self) ->BorrowedHandle<'_>
1.63.0 ·Source§impl<T:AsRawFd>AsRawFd forBox<T>
Available onUnix or HermitCore ortarget_os=trusty or WASI ortarget_os=motor only.
impl<T:AsRawFd>AsRawFd forBox<T>
target_os=trusty or WASI ortarget_os=motor only.1.71.0 ·Source§impl<T:AsSocket>AsSocket forBox<T>
Available onWindows only.
impl<T:AsSocket>AsSocket forBox<T>
Source§fnas_socket(&self) ->BorrowedSocket<'_>
fnas_socket(&self) ->BorrowedSocket<'_>
1.85.0 ·Source§impl<Args, F, A>AsyncFn<Args> forBox<F, A>
impl<Args, F, A>AsyncFn<Args> forBox<F, A>
Source§extern "rust-call" fnasync_call( &self, args: Args,) -> <Box<F, A> asAsyncFnMut<Args>>::CallRefFuture<'_>
extern "rust-call" fnasync_call( &self, args: Args,) -> <Box<F, A> asAsyncFnMut<Args>>::CallRefFuture<'_>
async_fn_traits)AsyncFn, returning a future which may borrow from the called closure.1.85.0 ·Source§impl<Args, F, A>AsyncFnMut<Args> forBox<F, A>
impl<Args, F, A>AsyncFnMut<Args> forBox<F, A>
Source§typeCallRefFuture<'a> = <F asAsyncFnMut<Args>>::CallRefFuture<'a>whereBox<F, A>: 'a
typeCallRefFuture<'a> = <F asAsyncFnMut<Args>>::CallRefFuture<'a>whereBox<F, A>: 'a
async_fn_traits)AsyncFnMut::async_call_mut andAsyncFn::async_call.Source§extern "rust-call" fnasync_call_mut( &mut self, args: Args,) -> <Box<F, A> asAsyncFnMut<Args>>::CallRefFuture<'_>
extern "rust-call" fnasync_call_mut( &mut self, args: Args,) -> <Box<F, A> asAsyncFnMut<Args>>::CallRefFuture<'_>
async_fn_traits)AsyncFnMut, returning a future which may borrow from the called closure.1.85.0 ·Source§impl<Args, F, A>AsyncFnOnce<Args> forBox<F, A>
impl<Args, F, A>AsyncFnOnce<Args> forBox<F, A>
Source§typeOutput = <F asAsyncFnOnce<Args>>::Output
typeOutput = <F asAsyncFnOnce<Args>>::Output
async_fn_traits)Source§typeCallOnceFuture = <F asAsyncFnOnce<Args>>::CallOnceFuture
typeCallOnceFuture = <F asAsyncFnOnce<Args>>::CallOnceFuture
async_fn_traits)AsyncFnOnce::async_call_once.Source§extern "rust-call" fnasync_call_once( self, args: Args,) -> <Box<F, A> asAsyncFnOnce<Args>>::CallOnceFuture
extern "rust-call" fnasync_call_once( self, args: Args,) -> <Box<F, A> asAsyncFnOnce<Args>>::CallOnceFuture
async_fn_traits)AsyncFnOnce, returning a future which may move out of the called closure.Source§impl<S>AsyncIterator forBox<S>
impl<S>AsyncIterator forBox<S>
Source§typeItem = <S asAsyncIterator>::Item
typeItem = <S asAsyncIterator>::Item
async_iterator #79024)Source§fnpoll_next( self:Pin<&mutBox<S>>, cx: &mutContext<'_>,) ->Poll<Option<<Box<S> asAsyncIterator>::Item>>
fnpoll_next( self:Pin<&mutBox<S>>, cx: &mutContext<'_>,) ->Poll<Option<<Box<S> asAsyncIterator>::Item>>
async_iterator #79024)None if the async iterator is exhausted.Read more1.1.0 ·Source§impl<T, A>BorrowMut<T> forBox<T, A>
impl<T, A>BorrowMut<T> forBox<T, A>
Source§fnborrow_mut(&mut self) ->&mut T
fnborrow_mut(&mut self) ->&mut T
1.0.0 ·Source§impl<B:BufRead + ?Sized>BufRead forBox<B>
impl<B:BufRead + ?Sized>BufRead forBox<B>
Source§fnfill_buf(&mut self) ->Result<&[u8]>
fnfill_buf(&mut self) ->Result<&[u8]>
Read methods, if empty.Read moreSource§fnconsume(&mut self, amt:usize)
fnconsume(&mut self, amt:usize)
amount of additional bytes from the internal buffer as having been read.Subsequent calls toread only return bytes that have not been marked as read.Read moreSource§fnhas_data_left(&mut self) ->Result<bool>
fnhas_data_left(&mut self) ->Result<bool>
buf_read_has_data_left #86423)read.Read moreSource§fnskip_until(&mut self, byte:u8) ->Result<usize>
fnskip_until(&mut self, byte:u8) ->Result<usize>
byte or EOF is reached.Read moreSource§fnread_line(&mut self, buf: &mutString) ->Result<usize>
fnread_line(&mut self, buf: &mutString) ->Result<usize>
0xA byte) is reached, and appendthem to the providedString buffer.Read more1.3.0 ·Source§impl<T, A>Clone forBox<[T], A>
impl<T, A>Clone forBox<[T], A>
1.0.0 ·Source§impl<T, A>Clone forBox<T, A>
impl<T, A>Clone forBox<T, A>
Source§impl<G, R, A>Coroutine<R> forBox<G, A>
impl<G, R, A>Coroutine<R> forBox<G, A>
Source§typeYield = <G asCoroutine<R>>::Yield
typeYield = <G asCoroutine<R>>::Yield
coroutine_trait #43122)Source§impl<G, R, A>Coroutine<R> forPin<Box<G, A>>
impl<G, R, A>Coroutine<R> forPin<Box<G, A>>
Source§typeYield = <G asCoroutine<R>>::Yield
typeYield = <G asCoroutine<R>>::Yield
coroutine_trait #43122)1.0.0 ·Source§impl<I, A>DoubleEndedIterator forBox<I, A>
impl<I, A>DoubleEndedIterator forBox<I, A>
Source§fnnext_back(&mut self) ->Option<<I asIterator>::Item>
fnnext_back(&mut self) ->Option<<I asIterator>::Item>
Source§fnnth_back(&mut self, n:usize) ->Option<<I asIterator>::Item>
fnnth_back(&mut self, n:usize) ->Option<<I asIterator>::Item>
nth element from the end of the iterator.Read moreSource§fnadvance_back_by(&mut self, n:usize) ->Result<(),NonZero<usize>>
fnadvance_back_by(&mut self, n:usize) ->Result<(),NonZero<usize>>
iter_advance_by #77404)n elements.Read more1.27.0 ·Source§fntry_rfold<B, F, R>(&mut self, init: B, f: F) -> R
fntry_rfold<B, F, R>(&mut self, init: B, f: F) -> R
Iterator::try_fold(): it takeselements starting from the back of the iterator.Read more1.8.0 ·Source§impl<E>Error forBox<E>where E:Error,
impl<E>Error forBox<E>where E:Error,
Source§fncause(&self) ->Option<&dynError>
fncause(&self) ->Option<&dynError>
Source§fnsource(&self) ->Option<&(dynError + 'static)>
fnsource(&self) ->Option<&(dynError + 'static)>
Source§fnprovide<'b>(&'b self, request: &mutRequest<'b>)
fnprovide<'b>(&'b self, request: &mutRequest<'b>)
error_generic_member_access #99301)1.0.0 ·Source§fndescription(&self) -> &str
fndescription(&self) -> &str
1.0.0 ·Source§impl<I, A>ExactSizeIterator forBox<I, A>
impl<I, A>ExactSizeIterator forBox<I, A>
1.45.0 ·Source§impl<A>Extend<Box<str, A>> forStringwhere A:Allocator,
impl<A>Extend<Box<str, A>> forStringwhere A:Allocator,
1.17.0 ·Source§impl<T>From<&[T]> forBox<[T]>where T:Clone,
impl<T>From<&[T]> forBox<[T]>where T:Clone,
1.84.0 ·Source§impl<T>From<&mut[T]> forBox<[T]>where T:Clone,
impl<T>From<&mut[T]> forBox<[T]>where T:Clone,
1.0.0 ·Source§impl<'a>From<&str> forBox<dynError +Send +Sync + 'a>
impl<'a>From<&str> forBox<dynError +Send +Sync + 'a>
1.33.0 ·Source§impl<T, A>From<Box<T, A>> forPin<Box<T, A>>
impl<T, A>From<Box<T, A>> forPin<Box<T, A>>
Source§fnfrom(boxed:Box<T, A>) ->Pin<Box<T, A>>
fnfrom(boxed:Box<T, A>) ->Pin<Box<T, A>>
Converts aBox<T> into aPin<Box<T>>. IfT does not implementUnpin, 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 viaBox::into_pin.
Constructing and pinning aBox with<Pin<Box<T>>>::from(Box::new(x))can also be written more concisely usingBox::pin(x).ThisFrom implementation is useful if you already have aBox<T>, or you areconstructing a (pinned)Box in a different way than withBox::new.
1.19.0 ·Source§impl<A>From<Box<str, A>> forBox<[u8], A>where A:Allocator,
impl<A>From<Box<str, A>> forBox<[u8], A>where A:Allocator,
Source§fnfrom(s:Box<str, A>) ->Box<[u8], A>
fnfrom(s:Box<str, A>) ->Box<[u8], A>
Converts aBox<str> into aBox<[u8]>
This conversion does not allocate on the heap and happens in place.
§Examples
// create a Box<str> which will be used to create a Box<[u8]>letboxed: Box<str> = Box::from("hello");letboxed_str: Box<[u8]> = Box::from(boxed);// create a &[u8] which will be used to create a Box<[u8]>letslice:&[u8] =&[104,101,108,108,111];letboxed_slice = Box::from(slice);assert_eq!(boxed_slice, boxed_str);1.45.0 ·Source§implFrom<Cow<'_,str>> forBox<str>
implFrom<Cow<'_,str>> forBox<str>
Source§fnfrom(cow:Cow<'_,str>) ->Box<str>
fnfrom(cow:Cow<'_,str>) ->Box<str>
Converts aCow<'_, str> into aBox<str>
Whencow is theCow::Borrowed variant, thisconversion allocates on the heap and copies theunderlyingstr. Otherwise, it will try to reuse the ownedString’s allocation.
§Examples
1.22.0 ·Source§impl<'a, 'b>From<Cow<'b,str>> forBox<dynError + 'a>
impl<'a, 'b>From<Cow<'b,str>> forBox<dynError + 'a>
1.22.0 ·Source§impl<'a, 'b>From<Cow<'b,str>> forBox<dynError +Send +Sync + 'a>
impl<'a, 'b>From<Cow<'b,str>> forBox<dynError +Send +Sync + 'a>
1.0.0 ·Source§impl<'a, E>From<E> forBox<dynError + 'a>where E:Error + 'a,
impl<'a, E>From<E> forBox<dynError + 'a>where E:Error + 'a,
Source§fnfrom(err: E) ->Box<dynError + 'a>
fnfrom(err: E) ->Box<dynError + 'a>
Converts a type ofError into a box of dynError.
§Examples
usestd::error::Error;usestd::fmt;#[derive(Debug)]structAnError;implfmt::DisplayforAnError {fnfmt(&self, f:&mutfmt::Formatter<'_>) -> fmt::Result {write!(f,"An error") }}implErrorforAnError {}letan_error = AnError;assert!(0== size_of_val(&an_error));leta_boxed_error = Box::<dynError>::from(an_error);assert!(size_of::<Box<dynError>>() == size_of_val(&a_boxed_error))1.0.0 ·Source§impl<'a, E>From<E> forBox<dynError +Send +Sync + 'a>
impl<'a, E>From<E> forBox<dynError +Send +Sync + 'a>
Source§fnfrom(err: E) ->Box<dynError +Send +Sync + 'a>
fnfrom(err: E) ->Box<dynError +Send +Sync + 'a>
Converts a type ofError +Send +Sync into a box ofdynError +Send +Sync.
§Examples
usestd::error::Error;usestd::fmt;#[derive(Debug)]structAnError;implfmt::DisplayforAnError {fnfmt(&self, f:&mutfmt::Formatter<'_>) -> fmt::Result {write!(f,"An error") }}implErrorforAnError {}unsafe implSendforAnError {}unsafe implSyncforAnError {}letan_error = AnError;assert!(0== size_of_val(&an_error));leta_boxed_error = Box::<dynError + Send + Sync>::from(an_error);assert!( size_of::<Box<dynError + Send + Sync>>() == size_of_val(&a_boxed_error))1.0.0 ·Source§impl<'a>From<String> forBox<dynError +Send +Sync + 'a>
impl<'a>From<String> forBox<dynError +Send +Sync + 'a>
1.20.0 ·Source§impl<T, A>From<Vec<T, A>> forBox<[T], A>where A:Allocator,
impl<T, A>From<Vec<T, A>> forBox<[T], A>where A:Allocator,
1.32.0 ·Source§impl<I>FromIterator<I> forBox<[I]>
impl<I>FromIterator<I> forBox<[I]>
1.22.0 ·Source§impl<T, A>Hasher forBox<T, A>
impl<T, A>Hasher forBox<T, A>
Source§fnwrite_u128(&mut self, i:u128)
fnwrite_u128(&mut self, i:u128)
u128 into this hasher.Source§fnwrite_usize(&mut self, i:usize)
fnwrite_usize(&mut self, i:usize)
usize into this hasher.Source§fnwrite_i128(&mut self, i:i128)
fnwrite_i128(&mut self, i:i128)
i128 into this hasher.Source§fnwrite_isize(&mut self, i:isize)
fnwrite_isize(&mut self, i:isize)
isize into this hasher.1.0.0 ·Source§impl<I, A>Iterator forBox<I, A>
impl<I, A>Iterator forBox<I, A>
Source§fnnext(&mut self) ->Option<<I asIterator>::Item>
fnnext(&mut self) ->Option<<I asIterator>::Item>
Source§fnsize_hint(&self) -> (usize,Option<usize>)
fnsize_hint(&self) -> (usize,Option<usize>)
Source§fnnth(&mut self, n:usize) ->Option<<I asIterator>::Item>
fnnth(&mut self, n:usize) ->Option<<I asIterator>::Item>
nth element of the iterator.Read moreSource§fnlast(self) ->Option<<I asIterator>::Item>
fnlast(self) ->Option<<I asIterator>::Item>
Source§fnnext_chunk<const N:usize>( &mut self,) ->Result<[Self::Item;N],IntoIter<Self::Item, N>>where Self:Sized,
fnnext_chunk<const N:usize>( &mut self,) ->Result<[Self::Item;N],IntoIter<Self::Item, N>>where Self:Sized,
iter_next_chunk #98326)N values.Read more1.0.0 ·Source§fncount(self) ->usizewhere Self:Sized,
fncount(self) ->usizewhere Self:Sized,
Source§fnadvance_by(&mut self, n:usize) ->Result<(),NonZero<usize>>
fnadvance_by(&mut self, n:usize) ->Result<(),NonZero<usize>>
iter_advance_by #77404)n elements.Read more1.28.0 ·Source§fnstep_by(self, step:usize) ->StepBy<Self>ⓘwhere Self:Sized,
fnstep_by(self, step:usize) ->StepBy<Self>ⓘwhere Self:Sized,
1.0.0 ·Source§fnchain<U>(self, other: U) ->Chain<Self, <U asIntoIterator>::IntoIter>ⓘ
fnchain<U>(self, other: U) ->Chain<Self, <U asIntoIterator>::IntoIter>ⓘ
1.0.0 ·Source§fnzip<U>(self, other: U) ->Zip<Self, <U asIntoIterator>::IntoIter>ⓘwhere Self:Sized, U:IntoIterator,
fnzip<U>(self, other: U) ->Zip<Self, <U asIntoIterator>::IntoIter>ⓘwhere Self:Sized, U:IntoIterator,
Source§fnintersperse(self, separator: Self::Item) ->Intersperse<Self>ⓘ
fnintersperse(self, separator: Self::Item) ->Intersperse<Self>ⓘ
iter_intersperse #79524)separator between adjacentitems of the original iterator.Read moreSource§fnintersperse_with<G>(self, separator: G) ->IntersperseWith<Self, G>ⓘ
fnintersperse_with<G>(self, separator: G) ->IntersperseWith<Self, G>ⓘ
iter_intersperse #79524)separatorbetween adjacent items of the original iterator.Read more1.0.0 ·Source§fnmap<B, F>(self, f: F) ->Map<Self, F>ⓘ
fnmap<B, F>(self, f: F) ->Map<Self, F>ⓘ
1.0.0 ·Source§fnfilter<P>(self, predicate: P) ->Filter<Self, P>ⓘ
fnfilter<P>(self, predicate: P) ->Filter<Self, P>ⓘ
1.0.0 ·Source§fnfilter_map<B, F>(self, f: F) ->FilterMap<Self, F>ⓘ
fnfilter_map<B, F>(self, f: F) ->FilterMap<Self, F>ⓘ
1.0.0 ·Source§fnenumerate(self) ->Enumerate<Self>ⓘwhere Self:Sized,
fnenumerate(self) ->Enumerate<Self>ⓘwhere Self:Sized,
1.0.0 ·Source§fnskip_while<P>(self, predicate: P) ->SkipWhile<Self, P>ⓘ
fnskip_while<P>(self, predicate: P) ->SkipWhile<Self, P>ⓘ
1.0.0 ·Source§fntake_while<P>(self, predicate: P) ->TakeWhile<Self, P>ⓘ
fntake_while<P>(self, predicate: P) ->TakeWhile<Self, P>ⓘ
1.57.0 ·Source§fnmap_while<B, P>(self, predicate: P) ->MapWhile<Self, P>ⓘ
fnmap_while<B, P>(self, predicate: P) ->MapWhile<Self, P>ⓘ
1.0.0 ·Source§fnskip(self, n:usize) ->Skip<Self>ⓘwhere Self:Sized,
fnskip(self, n:usize) ->Skip<Self>ⓘwhere Self:Sized,
n elements.Read more1.0.0 ·Source§fntake(self, n:usize) ->Take<Self>ⓘwhere Self:Sized,
fntake(self, n:usize) ->Take<Self>ⓘwhere Self:Sized,
n elements, or fewerif the underlying iterator ends sooner.Read more1.0.0 ·Source§fnflat_map<U, F>(self, f: F) ->FlatMap<Self, U, F>ⓘ
fnflat_map<U, F>(self, f: F) ->FlatMap<Self, U, F>ⓘ
1.29.0 ·Source§fnflatten(self) ->Flatten<Self>ⓘ
fnflatten(self) ->Flatten<Self>ⓘ
Source§fnmap_windows<F, R, const N:usize>(self, f: F) ->MapWindows<Self, F, N>ⓘ
fnmap_windows<F, R, const N:usize>(self, f: F) ->MapWindows<Self, F, N>ⓘ
iter_map_windows #87155)f for each contiguous window of sizeN overself and returns an iterator over the outputs off. Likeslice::windows(),the windows during mapping overlap as well.Read more1.0.0 ·Source§fninspect<F>(self, f: F) ->Inspect<Self, F>ⓘ
fninspect<F>(self, f: F) ->Inspect<Self, F>ⓘ
1.0.0 ·Source§fnby_ref(&mut self) -> &mut Selfwhere Self:Sized,
fnby_ref(&mut self) -> &mut Selfwhere Self:Sized,
Iterator.Read moreSource§fntry_collect<B>( &mut self,) -> <<Self::Item asTry>::Residual asResidual<B>>::TryType
fntry_collect<B>( &mut self,) -> <<Self::Item asTry>::Residual asResidual<B>>::TryType
iterator_try_collect #94047)Source§fncollect_into<E>(self, collection:&mut E) ->&mut E
fncollect_into<E>(self, collection:&mut E) ->&mut E
iter_collect_into #94780)1.0.0 ·Source§fnpartition<B, F>(self, f: F) ->(B, B)
fnpartition<B, F>(self, f: F) ->(B, B)
Source§fnpartition_in_place<'a, T, P>(self, predicate: P) ->usize
fnpartition_in_place<'a, T, P>(self, predicate: P) ->usize
iter_partition_in_place #62543)true precede all those that returnfalse.Returns the number oftrue elements found.Read moreSource§fnis_partitioned<P>(self, predicate: P) ->bool
fnis_partitioned<P>(self, predicate: P) ->bool
iter_is_partitioned #62544)true precede all those that returnfalse.Read more1.27.0 ·Source§fntry_fold<B, F, R>(&mut self, init: B, f: F) -> R
fntry_fold<B, F, R>(&mut self, init: B, f: F) -> R
1.27.0 ·Source§fntry_for_each<F, R>(&mut self, f: F) -> R
fntry_for_each<F, R>(&mut self, f: F) -> R
1.0.0 ·Source§fnfold<B, F>(self, init: B, f: F) -> B
fnfold<B, F>(self, init: B, f: F) -> B
1.51.0 ·Source§fnreduce<F>(self, f: F) ->Option<Self::Item>
fnreduce<F>(self, f: F) ->Option<Self::Item>
Source§fntry_reduce<R>( &mut self, f: implFnMut(Self::Item, Self::Item) -> R,) -> <<R asTry>::Residual asResidual<Option<<R asTry>::Output>>>::TryType
fntry_reduce<R>( &mut self, f: implFnMut(Self::Item, Self::Item) -> R,) -> <<R asTry>::Residual asResidual<Option<<R asTry>::Output>>>::TryType
iterator_try_reduce #87053)1.0.0 ·Source§fnall<F>(&mut self, f: F) ->bool
fnall<F>(&mut self, f: F) ->bool
1.0.0 ·Source§fnany<F>(&mut self, f: F) ->bool
fnany<F>(&mut self, f: F) ->bool
1.0.0 ·Source§fnfind<P>(&mut self, predicate: P) ->Option<Self::Item>
fnfind<P>(&mut self, predicate: P) ->Option<Self::Item>
1.30.0 ·Source§fnfind_map<B, F>(&mut self, f: F) ->Option<B>
fnfind_map<B, F>(&mut self, f: F) ->Option<B>
Source§fntry_find<R>( &mut self, f: implFnMut(&Self::Item) -> R,) -> <<R asTry>::Residual asResidual<Option<Self::Item>>>::TryType
fntry_find<R>( &mut self, f: implFnMut(&Self::Item) -> R,) -> <<R asTry>::Residual asResidual<Option<Self::Item>>>::TryType
try_find #63178)1.0.0 ·Source§fnposition<P>(&mut self, predicate: P) ->Option<usize>
fnposition<P>(&mut self, predicate: P) ->Option<usize>
1.0.0 ·Source§fnrposition<P>(&mut self, predicate: P) ->Option<usize>
fnrposition<P>(&mut self, predicate: P) ->Option<usize>
1.6.0 ·Source§fnmax_by_key<B, F>(self, f: F) ->Option<Self::Item>
fnmax_by_key<B, F>(self, f: F) ->Option<Self::Item>
1.15.0 ·Source§fnmax_by<F>(self, compare: F) ->Option<Self::Item>
fnmax_by<F>(self, compare: F) ->Option<Self::Item>
1.6.0 ·Source§fnmin_by_key<B, F>(self, f: F) ->Option<Self::Item>
fnmin_by_key<B, F>(self, f: F) ->Option<Self::Item>
1.15.0 ·Source§fnmin_by<F>(self, compare: F) ->Option<Self::Item>
fnmin_by<F>(self, compare: F) ->Option<Self::Item>
1.0.0 ·Source§fnrev(self) ->Rev<Self>ⓘwhere Self:Sized +DoubleEndedIterator,
fnrev(self) ->Rev<Self>ⓘwhere Self:Sized +DoubleEndedIterator,
1.0.0 ·Source§fnunzip<A, B, FromA, FromB>(self) ->(FromA, FromB)
fnunzip<A, B, FromA, FromB>(self) ->(FromA, FromB)
1.36.0 ·Source§fncopied<'a, T>(self) ->Copied<Self>ⓘ
fncopied<'a, T>(self) ->Copied<Self>ⓘ
Source§fnarray_chunks<const N:usize>(self) ->ArrayChunks<Self, N>ⓘwhere Self:Sized,
fnarray_chunks<const N:usize>(self) ->ArrayChunks<Self, N>ⓘwhere Self:Sized,
iter_array_chunks #100450)N elements of the iterator at a time.Read more1.11.0 ·Source§fnproduct<P>(self) -> P
fnproduct<P>(self) -> P
Source§fncmp_by<I, F>(self, other: I, cmp: F) ->Ordering
fncmp_by<I, F>(self, other: I, cmp: F) ->Ordering
iter_order_by #64295)Iterator with thoseof another with respect to the specified comparison function.Read more1.5.0 ·Source§fnpartial_cmp<I>(self, other: I) ->Option<Ordering>
fnpartial_cmp<I>(self, other: I) ->Option<Ordering>
PartialOrd elements ofthisIterator with those of another. The comparison works like short-circuitevaluation, returning a result without comparing the remaining elements.As soon as an order can be determined, the evaluation stops and a result is returned.Read moreSource§fnpartial_cmp_by<I, F>(self, other: I, partial_cmp: F) ->Option<Ordering>
fnpartial_cmp_by<I, F>(self, other: I, partial_cmp: F) ->Option<Ordering>
iter_order_by #64295)Iterator with thoseof another with respect to the specified comparison function.Read moreSource§fneq_by<I, F>(self, other: I, eq: F) ->bool
fneq_by<I, F>(self, other: I, eq: F) ->bool
iter_order_by #64295)1.5.0 ·Source§fnle<I>(self, other: I) ->bool
fnle<I>(self, other: I) ->bool
Iterator arelexicographicallyless or equal to those of another.Read more1.5.0 ·Source§fngt<I>(self, other: I) ->bool
fngt<I>(self, other: I) ->bool
Iterator arelexicographicallygreater than those of another.Read more1.5.0 ·Source§fnge<I>(self, other: I) ->bool
fnge<I>(self, other: I) ->bool
Iterator arelexicographicallygreater than or equal to those of another.Read more1.82.0 ·Source§fnis_sorted_by<F>(self, compare: F) ->bool
fnis_sorted_by<F>(self, compare: F) ->bool
1.82.0 ·Source§fnis_sorted_by_key<F, K>(self, f: F) ->bool
fnis_sorted_by_key<F, K>(self, f: F) ->bool
1.0.0 ·Source§impl<T, A>Ord forBox<T, A>
impl<T, A>Ord forBox<T, A>
1.0.0 ·Source§impl<T, A>PartialOrd forBox<T, A>
impl<T, A>PartialOrd forBox<T, A>
1.0.0 ·Source§impl<R:Read + ?Sized>Read forBox<R>
impl<R:Read + ?Sized>Read forBox<R>
Source§fnread(&mut self, buf: &mut [u8]) ->Result<usize>
fnread(&mut self, buf: &mut [u8]) ->Result<usize>
Source§fnread_buf(&mut self, cursor:BorrowedCursor<'_>) ->Result<()>
fnread_buf(&mut self, cursor:BorrowedCursor<'_>) ->Result<()>
read_buf #78485)Source§fnread_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) ->Result<usize>
fnread_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) ->Result<usize>
read, except that it reads into a slice of buffers.Read moreSource§fnis_read_vectored(&self) ->bool
fnis_read_vectored(&self) ->bool
can_vector #69941)Source§fnread_to_end(&mut self, buf: &mutVec<u8>) ->Result<usize>
fnread_to_end(&mut self, buf: &mutVec<u8>) ->Result<usize>
buf.Read moreSource§fnread_to_string(&mut self, buf: &mutString) ->Result<usize>
fnread_to_string(&mut self, buf: &mutString) ->Result<usize>
buf.Read moreSource§fnread_exact(&mut self, buf: &mut [u8]) ->Result<()>
fnread_exact(&mut self, buf: &mut [u8]) ->Result<()>
buf.Read moreSource§fnread_buf_exact(&mut self, cursor:BorrowedCursor<'_>) ->Result<()>
fnread_buf_exact(&mut self, cursor:BorrowedCursor<'_>) ->Result<()>
read_buf #78485)cursor.Read more1.0.0 ·Source§fnby_ref(&mut self) -> &mut Selfwhere Self:Sized,
fnby_ref(&mut self) -> &mut Selfwhere Self:Sized,
Read.Read more1.0.0 ·Source§fnchain<R:Read>(self, next: R) ->Chain<Self, R>ⓘwhere Self:Sized,
fnchain<R:Read>(self, next: R) ->Chain<Self, R>ⓘwhere Self:Sized,
1.0.0 ·Source§impl<S:Seek + ?Sized>Seek forBox<S>
impl<S:Seek + ?Sized>Seek forBox<S>
Source§fnseek(&mut self, pos:SeekFrom) ->Result<u64>
fnseek(&mut self, pos:SeekFrom) ->Result<u64>
Source§fnstream_len(&mut self) ->Result<u64>
fnstream_len(&mut self) ->Result<u64>
seek_stream_len #59359)1.43.0 ·Source§impl<T, const N:usize>TryFrom<Box<[T]>> forBox<[T; N]>
impl<T, const N:usize>TryFrom<Box<[T]>> forBox<[T; N]>
Source§fntry_from( boxed_slice:Box<[T]>,) ->Result<Box<[T; N]>, <Box<[T; N]> asTryFrom<Box<[T]>>>::Error>
fntry_from( boxed_slice:Box<[T]>,) ->Result<Box<[T; N]>, <Box<[T; N]> asTryFrom<Box<[T]>>>::Error>
Attempts to convert aBox<[T]> into aBox<[T; N]>.
The conversion occurs in-place and does not require anew memory allocation.
§Errors
Returns the oldBox<[T]> in theErr variant ifboxed_slice.len() does not equalN.
1.66.0 ·Source§impl<T, const N:usize>TryFrom<Vec<T>> forBox<[T; N]>
impl<T, const N:usize>TryFrom<Vec<T>> forBox<[T; N]>
Source§fntry_from( vec:Vec<T>,) ->Result<Box<[T; N]>, <Box<[T; N]> asTryFrom<Vec<T>>>::Error>
fntry_from( vec:Vec<T>,) ->Result<Box<[T; N]>, <Box<[T; N]> asTryFrom<Vec<T>>>::Error>
Attempts to convert aVec<T> into aBox<[T; N]>.
LikeVec::into_boxed_slice, this is in-place ifvec.capacity() == N,but will require a reallocation otherwise.
§Errors
Returns the originalVec<T> in theErr variant ifboxed_slice.len() does not equalN.
§Examples
This can be used withvec! to create an array on the heap:
1.0.0 ·Source§impl<W:Write + ?Sized>Write forBox<W>
impl<W:Write + ?Sized>Write forBox<W>
Source§fnwrite(&mut self, buf: &[u8]) ->Result<usize>
fnwrite(&mut self, buf: &[u8]) ->Result<usize>
Source§fnis_write_vectored(&self) ->bool
fnis_write_vectored(&self) ->bool
can_vector #69941)Source§fnflush(&mut self) ->Result<()>
fnflush(&mut self) ->Result<()>
Source§fnwrite_all(&mut self, buf: &[u8]) ->Result<()>
fnwrite_all(&mut self, buf: &[u8]) ->Result<()>
Source§fnwrite_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) ->Result<()>
fnwrite_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) ->Result<()>
write_all_vectored #70436)impl<T, U, A>CoerceUnsized<Box<U, A>> forBox<T, A>
impl<T, A>DerefPure forBox<T, A>
impl<T, U>DispatchFromDyn<Box<U>> forBox<T>
impl<T, A>Eq forBox<T, A>
impl<I, A>FusedIterator forBox<I, A>
impl<'a, I, A> !Iterator for &'aBox<[I], A>where A:Allocator,
This implementation is required to make sure that the&Box<[I]>: IntoIteratorimplementation doesn’t overlap withIntoIterator for T where T: Iterator blanket.
impl<'a, I, A> !Iterator for &'a mutBox<[I], A>where A:Allocator,
This implementation is required to make sure that the&mut Box<[I]>: IntoIteratorimplementation doesn’t overlap withIntoIterator for T where T: Iterator blanket.
impl<I, A> !Iterator forBox<[I], A>where A:Allocator,
This implementation is required to make sure that theBox<[I]>: IntoIteratorimplementation doesn’t overlap withIntoIterator for T where T: Iterator blanket.
impl<T, A>PinCoerceUnsized forBox<T, A>
impl<T, A>Unpin forBox<T, A>
Auto Trait Implementations§
impl<T, A>Freeze forBox<T, A>
impl<T, A>RefUnwindSafe forBox<T, A>
impl<T, A>Send forBox<T, A>
impl<T, A>Sync forBox<T, A>
impl<T, A>UnwindSafe forBox<T, A>
Blanket Implementations§
Source§impl<T>BorrowMut<T> for Twhere T: ?Sized,
impl<T>BorrowMut<T> for Twhere T: ?Sized,
Source§fnborrow_mut(&mut self) ->&mut T
fnborrow_mut(&mut self) ->&mut T
Source§impl<T>CloneToUninit for Twhere T:Clone,
impl<T>CloneToUninit for Twhere T:Clone,
Source§impl<I>IntoAsyncIterator for Iwhere I:AsyncIterator,
impl<I>IntoAsyncIterator for Iwhere I:AsyncIterator,
Source§typeItem = <I asAsyncIterator>::Item
typeItem = <I asAsyncIterator>::Item
async_iterator #79024)Source§typeIntoAsyncIter = I
typeIntoAsyncIter = I
async_iterator #79024)Source§fninto_async_iter(self) -> <I asIntoAsyncIterator>::IntoAsyncIter
fninto_async_iter(self) -> <I asIntoAsyncIterator>::IntoAsyncIter
async_iterator #79024)self into an async iteratorSource§impl<F>IntoFuture for Fwhere F:Future,
impl<F>IntoFuture for Fwhere F:Future,
Source§typeIntoFuture = F
typeIntoFuture = F
Source§fninto_future(self) -> <F asIntoFuture>::IntoFuture
fninto_future(self) -> <F asIntoFuture>::IntoFuture
Source§impl<I>IntoIterator for Iwhere I:Iterator,
impl<I>IntoIterator for Iwhere I:Iterator,
Source§impl<F>Pattern for F
impl<F>Pattern for F
Source§typeSearcher<'a> =CharPredicateSearcher<'a, F>
typeSearcher<'a> =CharPredicateSearcher<'a, F>
pattern #27721)Source§fninto_searcher<'a>(self, haystack: &'astr) ->CharPredicateSearcher<'a, F>
fninto_searcher<'a>(self, haystack: &'astr) ->CharPredicateSearcher<'a, F>
pattern #27721)self and thehaystack to search in.Source§fnis_contained_in<'a>(self, haystack: &'astr) ->bool
fnis_contained_in<'a>(self, haystack: &'astr) ->bool
pattern #27721)Source§fnis_prefix_of<'a>(self, haystack: &'astr) ->bool
fnis_prefix_of<'a>(self, haystack: &'astr) ->bool
pattern #27721)Source§fnstrip_prefix_of<'a>(self, haystack: &'astr) ->Option<&'astr>
fnstrip_prefix_of<'a>(self, haystack: &'astr) ->Option<&'astr>
pattern #27721)Source§fnis_suffix_of<'a>(self, haystack: &'astr) ->boolwhereCharPredicateSearcher<'a, F>:ReverseSearcher<'a>,
fnis_suffix_of<'a>(self, haystack: &'astr) ->boolwhereCharPredicateSearcher<'a, F>:ReverseSearcher<'a>,
pattern #27721)Source§fnstrip_suffix_of<'a>(self, haystack: &'astr) ->Option<&'astr>whereCharPredicateSearcher<'a, F>:ReverseSearcher<'a>,
fnstrip_suffix_of<'a>(self, haystack: &'astr) ->Option<&'astr>whereCharPredicateSearcher<'a, F>:ReverseSearcher<'a>,
pattern #27721)Source§fnas_utf8_pattern(&self) ->Option<Utf8Pattern<'_>>
fnas_utf8_pattern(&self) ->Option<Utf8Pattern<'_>>
pattern #27721)