pub struct Array {
pub values: Vec<Value>,
}
Expand description
Represents an array of Value
s.
Fields§
§values: Vec<Value>
Implementations§
Source§impl Array
impl Array
Sourcepub fn new() -> Array
pub fn new() -> Array
Creates a new empty Array
.
§Examples
use my_crate::Array;
let empty_array = Array::new();
assert_eq!(empty_array.len(), 0);
Sourcepub fn get(&self, index: usize) -> Option<&Value>
pub fn get(&self, index: usize) -> Option<&Value>
Returns a reference to the value at the specified index, or None
if the index is out of bounds.
Sourcepub fn get_mut(&mut self, index: usize) -> Option<&mut Value>
pub fn get_mut(&mut self, index: usize) -> Option<&mut Value>
Returns a mutable reference to the value at the specified index, or None
if the index is out of bounds.
pub fn clean(&mut self)
Sourcepub fn push(&mut self, value: Value)
pub fn push(&mut self, value: Value)
Appends a value to the end of the array.
§Examples
use my_crate::{Array, Value};
let mut array = Array::new();
array.push(Value::from(42));
array.push(Value::from("hello"));
assert_eq!(array.len(), 2);
assert_eq!(array.get(0), Some(&Value::from(42)));
assert_eq!(array.get(1), Some(&Value::from("hello")));
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Trait Implementations§
Source§impl ArrayBehavior for Array
impl ArrayBehavior for Array
Source§impl<'a> IntoIterator for &'a Array
impl<'a> IntoIterator for &'a Array
Source§impl<'a> IntoIterator for &'a mut Array
impl<'a> IntoIterator for &'a mut Array
Source§impl IntoIterator for Array
impl IntoIterator for Array
Source§impl PartialOrd for Array
impl PartialOrd for Array
Source§impl ToValueBehavior for Array
impl ToValueBehavior for Array
impl PrimitiveType for Array
impl StructuralPartialEq for Array
Auto Trait Implementations§
impl Freeze for Array
impl RefUnwindSafe for Array
impl Send for Array
impl Sync for Array
impl Unpin for Array
impl UnwindSafe for Array
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more