[][src]Struct runestick::Vec

#[repr(transparent)]pub struct Vec { /* fields omitted */ }

Struct representing a dynamic vector.

Examples

let mut vec = runestick::Vec::new();
assert!(vec.is_empty());

vec.push_value(42)?;
vec.push_value(true)?;
assert_eq!(2, vec.len());

assert_eq!(Some(42), vec.get_value(0)?);
assert_eq!(Some(true), vec.get_value(1)?);
assert_eq!(None::<bool>, vec.get_value(2)?);

Implementations

impl Vec[src]

pub const fn new() -> Self[src]

Construct a new empty dynamic vector.

pub fn with_capacity(cap: usize) -> Self[src]

Construct a new dynamic vector guaranteed to have at least the given capacity.

pub fn into_inner(self) -> Vec<Value>[src]

Convert into inner std vector.

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

Returns true if the dynamic vector contains no elements.

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

Returns the number of elements in the dynamic vector, also referred to as its 'length'.

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

Appends an element to the back of a dynamic vector.

pub fn push_value<T>(&mut self, value: T) -> Result<(), VmError> where
    T: ToValue
[src]

Appends an element to the back of a dynamic vector, converting it as necessary through the ToValue trait.

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

Get the value at the given index.

pub fn get_value<T>(&self, index: usize) -> Result<Option<T>, VmError> where
    T: FromValue
[src]

Get the given value at the given index.

pub fn get_mut(&mut self, index: usize) -> Option<&mut Value>[src]

Get the mutable value at the given index.

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

Removes the last element from a dynamic vector and returns it, or None if it is empty.

pub fn clear(&mut self)[src]

Clears the vector, removing all values.

Note that this method has no effect on the allocated capacity of the vector.

pub fn extend(&mut self, interface: Interface) -> Result<(), VmError>[src]

Extend this vector with something that implements the into_iter protocol.

pub fn into_iterator(&self) -> Iterator[src]

Convert into a runestick iterator.

Trait Implementations

impl Clone for Vec[src]

impl Debug for Vec[src]

impl Deref for Vec[src]

type Target = [Value]

The resulting type after dereferencing.

impl DerefMut for Vec[src]

impl From<Box<[Value]>> for Vec[src]

impl From<Vec<Value>> for Vec[src]

impl From<Vec> for Value[src]

impl FromValue for Vec[src]

impl IntoIterator for Vec[src]

type Item = Value

The type of the elements being iterated over.

type IntoIter = IntoIter<Value>

Which kind of iterator are we turning this into?

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

type Item = &'a Value

The type of the elements being iterated over.

type IntoIter = Iter<'a, Value>

Which kind of iterator are we turning this into?

impl<'a> IntoIterator for &'a mut Vec[src]

type Item = &'a mut Value

The type of the elements being iterated over.

type IntoIter = IterMut<'a, Value>

Which kind of iterator are we turning this into?

impl Named for Vec[src]

impl ToValue for Vec[src]

impl TypeOf for Vec[src]

impl<'a> UnsafeFromValue for &'a Vec[src]

type Output = *const Vec

The output type from the unsafe coercion.

type Guard = RawRef

The raw guard returned. Read more

impl<'a> UnsafeFromValue for &'a mut Vec[src]

type Output = *mut Vec

The output type from the unsafe coercion.

type Guard = RawMut

The raw guard returned. Read more

Auto Trait Implementations

impl !RefUnwindSafe for Vec

impl !Send for Vec

impl !Sync for Vec

impl Unpin for Vec

impl !UnwindSafe for Vec

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<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

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.