[−][src]Struct runestick::Vec
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]
T: ToValue,
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]
T: FromValue,
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]
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]
fn from_value(value: Value) -> Result<Self, VmError>
[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?
fn into_iter(self) -> Self::IntoIter
[src]
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?
fn into_iter(self) -> Self::IntoIter
[src]
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?
fn into_iter(self) -> Self::IntoIter
[src]
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
fn from_value(value: Value) -> Result<(Self::Output, Self::Guard), VmError>
[src]
unsafe fn unsafe_coerce(output: Self::Output) -> Self
[src]
impl<'a> UnsafeFromValue for &'a mut Vec
[src]
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
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?
fn into_iter(self) -> I
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,