[][src]Struct artichoke_backend::extn::core::array::Array

pub struct Array(_);

Contiguous growable vector that implement the [Ruby Array] API for sys::mrb_value elements.

Array is a growable vector with potentially heap-allocated contents. Array implements the small vector optimization using spinoso_array::SmallArray. This type can be passed by pointer over FFI to the underlying mruby VM (this is why it stores sys::mrb_value rather than Value.

Array implements BoxUnboxVmValue which enables it to be serialized to a mruby value and unboxed to the Rust Array type.

Implementations

impl Array[src]

#[must_use]pub fn new() -> Self[src]

#[must_use]pub fn with_capacity(capacity: usize) -> Self[src]

#[must_use]pub fn assoc(one: Value, two: Value) -> Self[src]

#[must_use]pub fn iter(&self) -> Iter<'_>

Notable traits for Iter<'a>

impl<'a> Iterator for Iter<'a> type Item = Value;
[src]

#[must_use]pub fn len(&self) -> usize[src]

#[must_use]pub fn capacity(&self) -> usize[src]

#[must_use]pub fn as_mut_ptr(&mut self) -> *mut mrb_value[src]

#[must_use]pub fn is_empty(&self) -> bool[src]

pub fn clear(&mut self)[src]

pub fn initialize(
    interp: &mut Artichoke,
    first: Option<Value>,
    second: Option<Value>,
    block: Option<Block>
) -> Result<Self, Error>
[src]

pub fn repeat(&self, n: usize) -> Result<Self, ArgumentError>[src]

pub fn join(&self, interp: &mut Artichoke, sep: &[u8]) -> Result<Vec<u8>, Error>[src]

#[must_use]pub fn get(&self, index: usize) -> Option<Value>[src]

pub fn set(&mut self, index: usize, elem: Value)[src]

pub fn pop(&mut self) -> Option<Value>[src]

pub fn push(&mut self, elem: Value)[src]

pub fn reverse(&mut self)[src]

pub fn shift(&mut self) -> Option<Value>[src]

pub fn shift_n(&mut self, count: usize) -> Self[src]

#[must_use]pub unsafe fn from_raw_parts(
    ptr: *mut mrb_value,
    length: usize,
    capacity: usize
) -> Self
[src]

Creates an Array<T> directly from the raw components of another array.

Safety

This is highly unsafe, due to the number of invariants that aren't checked:

  • ptr needs to have been previously allocated via Array<T> (at least, it's highly likely to be incorrect if it wasn't).
  • T needs to have the same size and alignment as what ptr was allocated with. (T having a less strict alignment is not sufficient, the alignment really needs to be equal to satisfy the dealloc requirement that memory must be allocated and deallocated with the same layout.)
  • length needs to be less than or equal to capacity.
  • capacity needs to be the capacity that the pointer was allocated with.

Violating these may cause problems like corrupting the allocator's internal data structures.

The ownership of ptr is effectively transferred to the Array<T> which may then deallocate, reallocate or change the contents of memory pointed to by the pointer at will. Ensure that nothing else uses the pointer after calling this function.

#[must_use]pub fn into_raw_parts(self) -> (*mut mrb_value, usize, usize)[src]

Decomposes an Array<T> into its raw components.

Returns the raw pointer to the underlying data, the length of the array (in elements), and the allocated capacity of the data (in elements). These are the same arguments in the same order as the arguments to from_raw_parts.

After calling this function, the caller is responsible for the memory previously managed by the Array. The only way to do this is to convert the raw pointer, length, and capacity back into a Array with the from_raw_parts function, allowing the destructor to perform the cleanup.

pub unsafe fn rebox_into_value(
    into: Value,
    ptr: *mut mrb_value,
    len: usize,
    capacity: usize
) -> Result<(), Error>
[src]

Pack the raw triple of an Array into an RArray-backed sys::mrb_value.

Safety

Calling this function takes ownership of the allocation pointed to by ptr. ptr or its source cannot be safely accessed until calling Array::from_raw_parts.

Trait Implementations

impl<'a> AsMut<Array> for UnboxedValueGuard<'a, Array>[src]

impl<'a> AsRef<Array> for UnboxedValueGuard<'a, Array>[src]

impl BoxUnboxVmValue for Array[src]

type Unboxed = Self

type Guarded = Array

impl Clone for Array[src]

impl Debug for Array[src]

impl Default for Array[src]

impl Extend<Value> for Array[src]

impl Extend<mrb_value> for Array[src]

impl<'a> From<&'a [Value]> for Array[src]

impl<'a> From<&'a [mrb_value]> for Array[src]

impl From<Array<mrb_value>> for Array[src]

impl From<Vec<Value, Global>> for Array[src]

impl From<Vec<mrb_value, Global>> for Array[src]

impl<'a> FromIterator<&'a Option<Value>> for Array[src]

impl FromIterator<Option<Value>> for Array[src]

impl FromIterator<Value> for Array[src]

impl FromIterator<mrb_value> for Array[src]

impl<'a> IntoIterator for &'a Array[src]

type Item = Value

The type of the elements being iterated over.

type IntoIter = Iter<'a>

Which kind of iterator are we turning this into?

Auto Trait Implementations

impl RefUnwindSafe for Array[src]

impl !Send for Array[src]

impl !Sync for Array[src]

impl Unpin for Array[src]

impl UnwindSafe for Array[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 
[src]