Struct rune::alloc::boxed::Box

source ·
pub struct Box<T, A = Global>
where A: Allocator, T: ?Sized,
{ /* private fields */ }
Expand description

A pointer type that uniquely owns a heap allocation of type T.

Implementations§

source§

impl<T> Box<T>

source

pub fn try_new(value: T) -> Result<Box<T>, AllocError>

Allocates memory on the heap and then places x into it.

This doesn’t actually allocate if T is zero-sized.

§Examples
use rune::alloc::Box;

let five = Box::try_new(5)?;
source

pub fn try_pin(x: T) -> Result<Pin<Box<T>>, AllocError>

Constructs a new Pin<Box<T>>. If T does not implement Unpin, then x will be pinned in memory and unable to be moved.

Constructing and pinning of the Box can also be done in two steps: Box::try?pin(x) does the same as Box::into_pin([Box::try?new](x)). Consider using into_pin if you already have a Box<T>, or if you want to construct a (pinned) Box in a different way than with Box::try_new.

source§

impl<T> Box<T>
where T: ?Sized,

source

pub fn from_std(b: Box<T>) -> Result<Box<T>, Error>

Convert from a std Box.

This causes the underlying allocation to be accounted for by the Global allocator.

A caveat of this method is that the allocation is already in use, but this might still be necessary because we want access to certain methods in std Box such as the ability to coerce to unsized values.

§Examples
use rune::alloc::{Box, Vec};
use rune::alloc::limit;
use std::boxed::Box as StdBox;

assert_eq!(limit::get(), usize::MAX);

let b: StdBox<dyn Iterator<Item = u32>> = StdBox::new(1..3);
let mut b = Box::from_std(b)?;
assert_eq!(b.next(), Some(1));
assert_eq!(b.next(), Some(2));
assert_eq!(b.next(), None);

assert!(limit::get() < usize::MAX);
drop(b);

assert_eq!(limit::get(), usize::MAX);
source§

impl<T, A> Box<T, A>
where A: Allocator,

source

pub fn try_new_in(x: T, alloc: A) -> Result<Box<T, A>, AllocError>

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 rune::alloc::Box;
use rune::alloc::alloc::Global;

let five = Box::try_new_in(5, Global)?;
source

pub fn try_new_uninit_in(alloc: A) -> Result<Box<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 rune::alloc::Box;
use rune::alloc::alloc::Global;

let mut five = Box::<u32>::try_new_uninit_in(Global)?;

let five: Box<u32> = unsafe {
    // Deferred initialization:
    five.as_mut_ptr().write(5);

    five.assume_init()
};

assert_eq!(*five, 5);
source

pub fn into_inner(boxed: Box<T, A>) -> T

Consumes the Box, returning the wrapped value.

source§

impl<T, A> Box<T, A>
where A: Allocator, T: ?Sized,

source

pub fn leak<'a>(b: Box<T, A>) -> &'a mut T
where 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_in 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:

use rune::alloc::Box;

let x = Box::try_new(41)?;
let static_ref: &'static mut usize = Box::leak(x);
*static_ref += 1;
assert_eq!(*static_ref, 42);

Unsized data:

use rune::alloc::{try_vec, Box};

let x = try_vec![1, 2, 3].try_into_boxed_slice()?;
let static_ref = Box::leak(x);
static_ref[0] = 4;
assert_eq!(*static_ref, [4, 2, 3]);
source

pub fn into_pin(boxed: Box<T, A>) -> Pin<Box<T, A>>
where A: 'static,

Converts a Box<T> into a Pin<Box<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 Box with Box::into_pin([Box::try?new](x)) can also be written more concisely using [Box::try?pin](x). This into_pin method is useful if you already have a Box<T>, or you are constructing a (pinned) Box in a different way than with Box::try_new.

§Notes

It’s not recommended that crates add an impl like From<Box<T>> for Pin<T>, as it’ll introduce an ambiguity when calling Pin::from. A demonstration of such a poor impl is shown below.

use rune::alloc::Box;

struct Foo; // A type defined in this crate.
impl From<Box<()>> for Pin<Foo> {
    fn from(_: Box<()>) -> Pin<Foo> {
        Pin::new(Foo)
    }
}

let foo = Box::try_new(())?;
let bar = Pin::from(foo);
source

pub unsafe fn from_raw_in(raw: *mut T, alloc: A) -> Box<T, A>

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.

§Examples

Recreate a Box which was previously converted to a raw pointer using Box::into_raw_with_allocator:

use rune::alloc::Box;
use rune::alloc::alloc::Global;

let x = Box::try_new_in(5, Global)?;
let (ptr, alloc) = Box::into_raw_with_allocator(x);
let x = unsafe { Box::from_raw_in(ptr, alloc) };

Manually create a Box from scratch by using the system allocator:

use core::alloc::Layout;

use rune::alloc::Box;
use rune::alloc::alloc::{Allocator, Global};

unsafe {
    let ptr = Global.allocate(Layout::new::<i32>())?.as_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 = Box::from_raw_in(ptr, Global);
}
source

pub fn into_raw_with_allocator(b: Box<T, A>) -> (*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 rune::alloc::{Box, String};
use rune::alloc::alloc::Global;

let x = Box::try_new_in(String::try_from("Hello")?, Global)?;
let (ptr, alloc) = Box::into_raw_with_allocator(x);
let x = unsafe { Box::from_raw_in(ptr, alloc) };

Manual cleanup by explicitly running the destructor and deallocating the memory:

use core::alloc::Layout;
use core::ptr::{self, NonNull};

use rune::alloc::{Box, String};
use rune::alloc::alloc::{Allocator, Global};

let x = Box::try_new_in(String::try_from("Hello")?, Global)?;

let (ptr, alloc) = Box::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>());
}
source§

impl<T, A> Box<MaybeUninit<T>, A>
where A: Allocator,

source

pub unsafe fn assume_init(self) -> Box<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
use rune::alloc::Box;
use rune::alloc::alloc::Global;

let mut five = Box::<u32>::try_new_uninit_in(Global)?;

let five: Box<u32> = unsafe {
    // Deferred initialization:
    five.as_mut_ptr().write(5);

    five.assume_init()
};

assert_eq!(*five, 5);
source§

impl<T, A> Box<[T], A>
where A: Allocator,

source

pub fn try_new_uninit_slice_in( len: usize, alloc: A ) -> Result<Box<[MaybeUninit<T>], A>, Error>

Constructs a new boxed slice with uninitialized contents. Returns an error if the allocation fails

§Examples
use rune::alloc::Box;
use rune::alloc::alloc::Global;

let mut values = Box::<[u32]>::try_new_uninit_slice_in(3, Global)?;

let values = unsafe {
    // Deferred initialization:
    values[0].as_mut_ptr().write(1);
    values[1].as_mut_ptr().write(2);
    values[2].as_mut_ptr().write(3);
    values.assume_init()
};

assert_eq!(*values, [1, 2, 3]);
source§

impl<T, A> Box<[MaybeUninit<T>], A>
where A: Allocator,

source

pub unsafe fn assume_init(self) -> Box<[T], A>

Converts to Box<[T], A>.

§Safety

As with MaybeUninit::assume_init, it is up to the caller to guarantee that the values really are in an initialized state. Calling this when the content is not yet fully initialized causes immediate undefined behavior.

§Examples
use rune::alloc::Box;
use rune::alloc::alloc::Global;

let mut values = Box::<[u32]>::try_new_uninit_slice_in(3, Global)?;

let values = unsafe {
    // Deferred initialization:
    values[0].as_mut_ptr().write(1);
    values[1].as_mut_ptr().write(2);
    values[2].as_mut_ptr().write(3);
    values.assume_init()
};

assert_eq!(*values, [1, 2, 3]);

Trait Implementations§

source§

impl<T, A> AsMut<T> for Box<T, A>
where A: Allocator, T: ?Sized,

source§

fn as_mut(&mut self) -> &mut T

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl<T, A> AsRef<T> for Box<T, A>
where A: Allocator, T: ?Sized,

source§

fn as_ref(&self) -> &T

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<T, A> Borrow<T> for Box<T, A>
where A: Allocator, T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T, A> BorrowMut<T> for Box<T, A>
where A: Allocator, T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, A> Debug for Box<T, A>
where A: Allocator, T: Debug + ?Sized,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<T> Default for Box<[T]>

source§

fn default() -> Box<[T]>

Returns the “default value” for a type. Read more
source§

impl Default for Box<str>

source§

fn default() -> Box<str>

Returns the “default value” for a type. Read more
source§

impl<T, A> Deref for Box<T, A>
where A: Allocator, T: ?Sized,

§

type Target = T

The resulting type after dereferencing.
source§

fn deref(&self) -> &T

Dereferences the value.
source§

impl<T, A> DerefMut for Box<T, A>
where A: Allocator, T: ?Sized,

source§

fn deref_mut(&mut self) -> &mut T

Mutably dereferences the value.
source§

impl<'de, T> Deserialize<'de> for Box<[T]>
where T: Deserialize<'de>,

source§

fn deserialize<D>( deserializer: D ) -> Result<Box<[T]>, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<'de, T> Deserialize<'de> for Box<T>
where T: Deserialize<'de>,

source§

fn deserialize<D>( deserializer: D ) -> Result<Box<T>, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<'de> Deserialize<'de> for Box<str>

source§

fn deserialize<D>( deserializer: D ) -> Result<Box<str>, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<T, A> Display for Box<T, A>
where A: Allocator, T: Display + ?Sized,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<T, A> Drop for Box<T, A>
where A: Allocator, T: ?Sized,

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<T, A> From<Box<[T], A>> for Vec<T, A>
where A: Allocator,

source§

fn from(s: Box<[T], A>) -> Vec<T, A>

Convert a boxed slice into a vector by transferring ownership of the existing heap allocation.

§Examples
use rune::alloc::{Box, Vec};
use rune::alloc::try_vec;

let s: Box<[i32]> = Box::try_from([10, 40, 30])?;
let x: Vec<i32> = Vec::from(s);

assert_eq!(x, [10, 40, 30]);

let s: Box<[i32]> = try_vec![10, 40, 30].try_into_boxed_slice()?;
let x: Vec<i32> = Vec::from(s);

assert_eq!(x, [10, 40, 30]);
source§

impl From<Box<[Value]>> for OwnedTuple

source§

fn from(inner: Box<[Value]>) -> Self

Converts to this type from the input type.
source§

impl From<Box<[u8]>> for Bytes

source§

fn from(bytes: Box<[u8]>) -> Self

Converts to this type from the input type.
source§

impl<A> From<Box<str, A>> for Box<[u8], A>
where A: Allocator,

source§

fn from(value: Box<str, A>) -> Box<[u8], A>

Converts to this type from the input type.
source§

impl<A> From<Box<str, A>> for String<A>
where A: Allocator,

source§

fn from(s: Box<str, A>) -> String<A>

Converts the given boxed str slice to a String. It is notable that the str slice is owned.

§Examples

Basic usage:

use rune::alloc::{Box, String};

let s1: String = String::try_from("hello world")?;
let s2: Box<str> = s1.try_into_boxed_str()?;
let s3: String = String::from(s2);

assert_eq!("hello world", s3);
source§

impl FromValue for Box<str>

source§

fn from_value(value: Value) -> VmResult<Self>

Try to convert to the given type, from the given value.
source§

impl<T, A> Hash for Box<T, A>
where A: Allocator, T: Hash + ?Sized,

source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl IntoComponent for &Box<str>

source§

fn as_component_ref(&self) -> ComponentRef<'_>

Convert into a component directly.
source§

fn into_component(self) -> Result<Component, Error>

Convert into component.
source§

impl IntoComponent for Box<str>

source§

fn as_component_ref(&self) -> ComponentRef<'_>

Convert into a component directly.
source§

fn into_component(self) -> Result<Component, Error>

Convert into component.
source§

impl<T> OptionSpanned for Box<T>
where T: OptionSpanned,

source§

fn option_span(&self) -> Option<Span>

Get the optional span of the type.
source§

impl<T, A> Ord for Box<T, A>
where A: Allocator, T: Ord + ?Sized,

source§

fn cmp(&self, other: &Box<T, A>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl<T> Parse for Box<T>
where T: Parse,

Parse implementation for something that is boxed.

source§

fn parse(parser: &mut Parser<'_>) -> Result<Self>

Parse the current item from the parser.
source§

impl<T, A> PartialEq for Box<T, A>
where A: Allocator, T: PartialEq + ?Sized,

source§

fn eq(&self, other: &Box<T, A>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T, A> PartialOrd for Box<T, A>
where A: Allocator, T: PartialOrd + ?Sized,

source§

fn partial_cmp(&self, other: &Box<T, A>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<T> Peek for Box<T>
where T: Peek,

Peek implementation for something that is boxed.

source§

fn peek(p: &mut Peeker<'_>) -> bool

Peek the parser for the given token.
source§

impl<T> Serialize for Box<T>
where T: Serialize + ?Sized,

source§

fn serialize<S>( &self, serializer: S ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<T> Spanned for Box<T>
where T: Spanned,

source§

fn span(&self) -> Span

Get the span of the type.
source§

impl<T> ToTokens for Box<T>
where T: ToTokens,

source§

fn to_tokens( &self, context: &mut MacroContext<'_, '_, '_>, stream: &mut TokenStream ) -> Result<()>

Turn the current item into tokens.
source§

impl ToValue for Box<str>

source§

fn to_value(self) -> VmResult<Value>

Convert into a value.
source§

impl<T, A> TryClone for Box<[T], A>
where A: Allocator + Clone, T: TryClone,

source§

fn try_clone(&self) -> Result<Box<[T], A>, Error>

Try to clone the current value, raising an allocation error if it’s unsuccessful.
source§

fn try_clone_from(&mut self, source: &Self) -> Result<(), Error>

Performs copy-assignment from source. Read more
source§

impl<A> TryClone for Box<Path, A>
where A: Allocator + Clone,

source§

fn try_clone(&self) -> Result<Box<Path, A>, Error>

Try to clone the current value, raising an allocation error if it’s unsuccessful.
source§

fn try_clone_from(&mut self, source: &Self) -> Result<(), Error>

Performs copy-assignment from source. Read more
source§

impl<T, A> TryClone for Box<T, A>
where A: Allocator + Clone, T: TryClone,

source§

fn try_clone(&self) -> Result<Box<T, A>, Error>

Try to clone the current value, raising an allocation error if it’s unsuccessful.
source§

fn try_clone_from(&mut self, source: &Self) -> Result<(), Error>

Performs copy-assignment from source. Read more
source§

impl<A> TryClone for Box<str, A>
where A: Allocator + Clone,

source§

fn try_clone(&self) -> Result<Box<str, A>, Error>

Try to clone the current value, raising an allocation error if it’s unsuccessful.
source§

fn try_clone_from(&mut self, source: &Self) -> Result<(), Error>

Performs copy-assignment from source. Read more
source§

impl TryFrom<&[u8]> for Box<[u8]>

source§

fn try_from(values: &[u8]) -> Result<Box<[u8]>, Error>

Converts a &[u8] into a Box<[u8]>.

§Examples
use rune::alloc::Box;

let s: Box<[u8]> = Box::try_from(&b"Hello World"[..])?;
assert_eq!(s.as_ref(), b"Hello World");
§

type Error = Error

The type returned in the event of a conversion error.
source§

impl TryFrom<&Path> for Box<Path>

source§

fn try_from(path: &Path) -> Result<Box<Path>, Error>

Converts a &[u8] into a Box<[u8]>.

§Examples
use std::path::Path;
use rune::alloc::Box;

let path = Path::new("foo/bar");

let s: Box<Path> = Box::try_from(path)?;
assert_eq!(s.as_ref(), Path::new("foo/bar"));
§

type Error = Error

The type returned in the event of a conversion error.
source§

impl TryFrom<&str> for Box<str>

source§

fn try_from(values: &str) -> Result<Box<str>, Error>

Converts a &str into a Box<str>.

§Examples
use rune::alloc::Box;

let s: Box<str> = Box::try_from("Hello World")?;
assert_eq!(s.as_ref(), "Hello World");
§

type Error = Error

The type returned in the event of a conversion error.
source§

impl<T, const N: usize> TryFrom<[T; N]> for Box<[T]>

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(values: [T; N]) -> Result<Box<[T]>, Error>

Performs the conversion.
source§

impl TryFrom<Box<[ConstValue]>> for OwnedTuple

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(inner: Box<[ConstValue]>) -> Result<Self>

Performs the conversion.
source§

impl<T> TryFrom<Box<[T]>> for Box<[T]>

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(values: Box<[T]>) -> Result<Box<[T]>, Error>

Performs the conversion.
source§

impl TryFrom<Cow<'_, str>> for Box<str>

source§

fn try_from(s: Cow<'_, str>) -> Result<Box<str>, Error>

Converts the given String to a boxed str slice that is owned.

§Examples
use rune::alloc::Box;
use rune::alloc::borrow::Cow;

let s2: Box<str> = Box::try_from(Cow::Borrowed("Hello World"))?;

assert_eq!("Hello World", s2.as_ref());
§

type Error = Error

The type returned in the event of a conversion error.
source§

impl<A> TryFrom<String<A>> for Box<str, A>
where A: Allocator,

source§

fn try_from(s: String<A>) -> Result<Box<str, A>, Error>

Converts the given String to a boxed str slice that is owned.

§Examples
use rune::alloc::{String, Box};

let s1: String = String::try_from("Hello World")?;
let s2: Box<str> = Box::try_from("Hello World")?;

assert_eq!("Hello World", s2.as_ref());
§

type Error = Error

The type returned in the event of a conversion error.
source§

impl TryFrom<String> for Box<str>

source§

fn try_from(string: String) -> Result<Box<str>, Error>

Converts a std String into a Box<str>.

§Examples
use rune::alloc::Box;

let s = String::from("Hello World");
let s: Box<str> = Box::try_from(s)?;
assert_eq!(s.as_ref(), "Hello World");
§

type Error = Error

The type returned in the event of a conversion error.
source§

impl<T, A> TryFrom<Vec<T, A>> for Box<[T], A>
where A: Allocator,

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(vec: Vec<T, A>) -> Result<Box<[T], A>, Error>

Performs the conversion.
source§

impl<T, A> TryFromIteratorIn<T, A> for Box<[T], A>
where A: Allocator,

source§

fn try_from_iter_in<I>(iter: I, alloc: A) -> Result<Box<[T], A>, Error>
where I: IntoIterator<Item = T>,

Creates a value from an iterator within an allocator.
source§

impl<T, A> Eq for Box<T, A>
where A: Allocator, T: Eq + ?Sized,

source§

impl<T, A> Unpin for Box<T, A>
where A: Allocator + 'static, T: ?Sized,

Auto Trait Implementations§

§

impl<T: ?Sized, A> RefUnwindSafe for Box<T, A>

§

impl<T: ?Sized, A> Send for Box<T, A>
where A: Send, T: Send,

§

impl<T: ?Sized, A> Sync for Box<T, A>
where A: Sync, T: Sync,

§

impl<T: ?Sized, A> UnwindSafe for Box<T, A>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
source§

impl<T> EncodedChars for T
where T: AsRef<str>,

source§

fn start_ptr(&self) -> *const u8

Pointer to the start of the pattern Read more
source§

fn limit_ptr(&self) -> *const u8

Pointer to the limit of the pattern buffer Read more
source§

fn len(&self) -> usize

The length of this buffer
source§

fn encoding(&self) -> *mut OnigEncodingTypeST

The encoding of the contents of the buffer
source§

fn is_empty(&self) -> bool

Is the buffer empty?
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryFromIterator<T> for U

source§

fn try_from_iter<I>(iter: I) -> Result<U, Error>
where I: IntoIterator<Item = T>,

Creates a value from an iterator within an allocator.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> TryToOwned for T
where T: TryClone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn try_to_owned(&self) -> Result<T, Error>

Creates owned data from borrowed data, usually by cloning. Read more
source§

impl<T> TryToString for T
where T: Display,

source§

fn try_to_string(&self) -> Result<String, Error>

Converts the given value to a String. Read more
source§

impl<T> UnsafeToValue for T
where T: ToValue,

§

type Guard = ()

The type used to guard the unsafe value conversion.
source§

unsafe fn unsafe_to_value( self ) -> VmResult<(Value, <T as UnsafeToValue>::Guard)>

Convert into a value. Read more
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<T> Formattable for T
where T: Deref, <T as Deref>::Target: Formattable,

source§

impl<T> NumBytes for T
where T: Debug + AsRef<[u8]> + AsMut<[u8]> + PartialEq + Eq + PartialOrd + Ord + Hash + Borrow<[u8]> + BorrowMut<[u8]> + ?Sized,

source§

impl<T> Parsable for T
where T: Deref, <T as Deref>::Target: Parsable,