Struct mbox::mbox::MBox
[−]
[src]
pub struct MBox<T: ?Sized + Free>(_);
A malloc-backed box. This structure allows Rust to exchange objects with C without cloning.
Methods
impl<T: ?Sized + Free> MBox<T>
[src]
pub unsafe fn from_raw(ptr: *mut T) -> MBox<T>
[src]
Constructs a new malloc-backed box from a pointer allocated by malloc
. The content of the
pointer must be already initialized.
pub fn as_ptr(&self) -> *const T
[src]
Obtains the pointer owned by the box.
pub fn as_mut_ptr(&mut self) -> *mut T
[src]
Obtains the mutable pointer owned by the box.
impl<T: ?Sized + Free> MBox<T>
[src]
pub fn into_raw(self) -> *mut T
[src]
Consumes the box and returns the original pointer.
The caller is responsible for free
ing the pointer after this.
impl<T> MBox<T>
[src]
pub fn new(value: T) -> MBox<T>
[src]
Constructs a new malloc-backed box, and move an initialized value into it.
impl<T> MBox<[T]>
[src]
pub unsafe fn from_raw_parts(value: *mut T, len: usize) -> MBox<[T]>
[src]
Constructs a new malloc-backed slice from the pointer and the length (number of items).
The malloc
ed size of the pointer must be at least len * size_of::<T>()
. The content
must already been initialized.
impl<T: Clone> MBox<[T]>
[src]
pub fn from_slice(slice: &[T]) -> MBox<[T]>
[src]
Creates a new malloc
-boxed slice by cloning the content of an existing slice.
impl MBox<str>
[src]
pub unsafe fn from_raw_utf8_parts_unchecked(
value: *mut u8,
len: usize
) -> MBox<str>
[src]
value: *mut u8,
len: usize
) -> MBox<str>
Constructs a new malloc-backed string from the pointer and the length (number of UTF-8 code units).
The malloc
ed size of the pointer must be at least len
. The content must already been
initialized and be valid UTF-8.
pub unsafe fn from_raw_utf8_parts(
value: *mut u8,
len: usize
) -> Result<MBox<str>, Utf8Error>
[src]
value: *mut u8,
len: usize
) -> Result<MBox<str>, Utf8Error>
Constructs a new malloc-backed string from the pointer and the length (number of UTF-8 code units).
The malloc
ed size of the pointer must be at least len
. If the content does not contain
valid UTF-8, this method returns an Err
.
pub fn into_bytes(self) -> MBox<[u8]>
[src]
Converts the string into raw bytes.
pub unsafe fn from_utf8_unchecked(bytes: MBox<[u8]>) -> MBox<str>
[src]
Creates a string from raw bytes. The bytes must be valid UTF-8.
pub fn from_utf8(bytes: MBox<[u8]>) -> Result<MBox<str>, Utf8Error>
[src]
Creates a string from raw bytes. If the content does not contain valid UTF-8, this method
returns an Err
.
pub fn from_str(string: &str) -> MBox<str>
[src]
Creates a new malloc
-boxed string by cloning the content of an existing string slice.
Trait Implementations
impl<T: ?Sized + Free> Drop for MBox<T>
[src]
impl<T: ?Sized + Free> Deref for MBox<T>
[src]
type Target = T
The resulting type after dereferencing.
ⓘImportant traits for &'a mut Wfn deref(&self) -> &T
[src]
Dereferences the value.
impl<T: ?Sized + Free> StableDeref for MBox<T>
[src]
impl<T: ?Sized + Free> DerefMut for MBox<T>
[src]
ⓘImportant traits for &'a mut Wfn deref_mut(&mut self) -> &mut T
[src]
Mutably dereferences the value.
impl<T: ?Sized + Free> AsRef<T> for MBox<T>
[src]
impl<T: ?Sized + Free> AsMut<T> for MBox<T>
[src]
impl<T: ?Sized + Free> Borrow<T> for MBox<T>
[src]
ⓘImportant traits for &'a mut Wfn borrow(&self) -> &T
[src]
Immutably borrows from an owned value. Read more
impl<T: ?Sized + Free> BorrowMut<T> for MBox<T>
[src]
ⓘImportant traits for &'a mut Wfn borrow_mut(&mut self) -> &mut T
[src]
Mutably borrows from an owned value. Read more
impl<T: ?Sized + Free + Unsize<U>, U: ?Sized + Free> CoerceUnsized<MBox<U>> for MBox<T>
[src]
impl<T: ?Sized + Free> Pointer for MBox<T>
[src]
fn fmt(&self, formatter: &mut Formatter) -> FormatResult
[src]
Formats the value using the given formatter.
impl<T: ?Sized + Free + Debug> Debug for MBox<T>
[src]
fn fmt(&self, formatter: &mut Formatter) -> FormatResult
[src]
Formats the value using the given formatter. Read more
impl<T: ?Sized + Free + Display> Display for MBox<T>
[src]
fn fmt(&self, formatter: &mut Formatter) -> FormatResult
[src]
Formats the value using the given formatter. Read more
impl<T: ?Sized + Free + Hash> Hash for MBox<T>
[src]
fn hash<H: Hasher>(&self, state: &mut H)
[src]
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<U: ?Sized + Free, T: ?Sized + Free + PartialEq<U>> PartialEq<MBox<U>> for MBox<T>
[src]
fn eq(&self, other: &MBox<U>) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<T: ?Sized + Free + Eq> Eq for MBox<T>
[src]
impl<U: ?Sized + Free, T: ?Sized + Free + PartialOrd<U>> PartialOrd<MBox<U>> for MBox<T>
[src]
fn partial_cmp(&self, other: &MBox<U>) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<T: ?Sized + Free + Ord> Ord for MBox<T>
[src]
fn cmp(&self, other: &Self) -> Ordering
[src]
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
impl<T> From<T> for MBox<T>
[src]
impl<T: Clone> Clone for MBox<T>
[src]
fn clone(&self) -> MBox<T>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
[src]
Performs copy-assignment from source
. Read more
impl<T: Default> Default for MBox<T>
[src]
impl<T> Default for MBox<[T]>
[src]
impl<T: Clone> Clone for MBox<[T]>
[src]
fn clone(&self) -> Self
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T> FromIterator<T> for MBox<[T]>
[src]
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
[src]
Creates a value from an iterator. Read more
impl<T> IntoIterator for MBox<[T]>
[src]
type Item = T
The type of the elements being iterated over.
type IntoIter = MSliceIntoIter<T>
Which kind of iterator are we turning this into?
ⓘImportant traits for MSliceIntoIter<T>fn into_iter(self) -> MSliceIntoIter<T>
[src]
Creates an iterator from a value. Read more
impl<'a, T> IntoIterator for &'a MBox<[T]>
[src]
type Item = &'a T
The type of the elements being iterated over.
type IntoIter = Iter<'a, T>
Which kind of iterator are we turning this into?
ⓘImportant traits for Iter<'a, T>fn into_iter(self) -> Iter<'a, T>
[src]
Creates an iterator from a value. Read more
impl<'a, T> IntoIterator for &'a mut MBox<[T]>
[src]
type Item = &'a mut T
The type of the elements being iterated over.
type IntoIter = IterMut<'a, T>
Which kind of iterator are we turning this into?
ⓘImportant traits for IterMut<'a, T>fn into_iter(self) -> IterMut<'a, T>
[src]
Creates an iterator from a value. Read more