[][src]Struct ijson::array::IArray

#[repr(transparent)]pub struct IArray(_);

The IArray type is similar to a Vec<IValue>. The primary difference is that the length and capacity are stored inside the heap allocation, so that the IArray itself can be a single pointer.

Implementations

impl IArray[src]

pub fn new() -> Self[src]

Constructs a new empty IArray. Does not allocate.

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

Constructs a new IArray with the specified capacity. At least that many items can be added to the array without reallocating.

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

Returns the capacity of the array. This is the maximum number of items the array can hold without reallocating.

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

Returns the number of items currently stored in the array.

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

Returns true if the array is empty.

pub fn as_slice(&self) -> &[IValue][src]

Borrows a slice of IValues from the array

pub fn as_mut_slice(&mut self) -> &mut [IValue][src]

Borrows a mutable slice of IValues from the array

pub fn reserve(&mut self, additional: usize)[src]

Reserves space for at least this many additional items.

pub fn truncate(&mut self, len: usize)[src]

Truncates the array by removing items until it is no longer than the specified length. The capacity is unchanged.

pub fn clear(&mut self)[src]

Removes all items from the array. The capacity is unchanged.

pub fn insert(&mut self, index: usize, item: impl Into<IValue>)[src]

Inserts a new item into the array at the specified index. Any existing items on or after this index will be shifted down to accomodate this. For large arrays, insertions near the front will be slow as it will require shifting a large number of items.

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

Removes and returns the item at the specified index from the array. Any items after this index will be shifted back up to close the gap. For large arrays, removals from near the front will be slow as it will require shifting a large number of items.

If the order of the array is unimporant, consider using IArray::swap_remove.

If the index is outside the array bounds, None is returned.

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

Removes and returns the item at the specified index from the array by first swapping it with the item currently at the end of the array, and then popping that last item.

This can be more efficient than IArray::remove for large arrays, but will change the ordering of items within the array.

If the index is outside the array bounds, None is returned.

pub fn push(&mut self, item: impl Into<IValue>)[src]

Pushes a new item onto the back of the array.

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

Pops the last item from the array and returns it. If the array is empty, None is returned.

pub fn shrink_to_fit(&mut self)[src]

Shrinks the memory allocation used by the array such that its capacity becomes equal to its length.

Trait Implementations

impl AsMut<IValue> for IArray[src]

impl AsRef<[IValue]> for IArray[src]

impl AsRef<IValue> for IArray[src]

impl Borrow<[IValue]> for IArray[src]

impl Borrow<IValue> for IArray[src]

impl BorrowMut<[IValue]> for IArray[src]

impl BorrowMut<IValue> for IArray[src]

impl Clone for IArray[src]

impl Debug for IArray[src]

impl Default for IArray[src]

impl Deref for IArray[src]

type Target = [IValue]

The resulting type after dereferencing.

impl DerefMut for IArray[src]

impl<'de> Deserialize<'de> for IArray[src]

impl<'de> Deserializer<'de> for &'de IArray[src]

type Error = Error

The error type that can be returned if some error occurs during deserialization. Read more

impl Eq for IArray[src]

impl<U: Into<IValue>> Extend<U> for IArray[src]

impl<T: Into<IValue> + Clone, '_> From<&'_ [T]> for IArray[src]

impl From<IArray> for IValue[src]

impl<T: Into<IValue>> From<Vec<T>> for IArray[src]

impl<U: Into<IValue>> FromIterator<U> for IArray[src]

impl Hash for IArray[src]

impl<I: SliceIndex<[IValue]>> Index<I> for IArray[src]

type Output = I::Output

The returned type after indexing.

impl<I: SliceIndex<[IValue]>> IndexMut<I> for IArray[src]

impl IntoIterator for IArray[src]

type Item = IValue

The type of the elements being iterated over.

type IntoIter = IntoIter

Which kind of iterator are we turning this into?

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

type Item = &'a IValue

The type of the elements being iterated over.

type IntoIter = Iter<'a, IValue>

Which kind of iterator are we turning this into?

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

type Item = &'a mut IValue

The type of the elements being iterated over.

type IntoIter = IterMut<'a, IValue>

Which kind of iterator are we turning this into?

impl PartialEq<IArray> for IArray[src]

impl PartialOrd<IArray> for IArray[src]

impl Serialize for IArray[src]

impl<'a> TryFrom<&'a IValue> for &'a IArray[src]

type Error = ()

The type returned in the event of a conversion error.

impl<'a> TryFrom<&'a mut IValue> for &'a mut IArray[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<IValue> for IArray[src]

type Error = IValue

The type returned in the event of a conversion error.

Auto Trait Implementations

impl RefUnwindSafe for IArray

impl Send for IArray

impl Sync for IArray

impl Unpin for IArray

impl UnwindSafe for IArray

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> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[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.