style::properties

Type Alias SubpropertiesVec

source
pub type SubpropertiesVec<T> = ArrayVec<T, { property_counts::MAX_SHORTHAND_EXPANDED }>;
Expand description

An ArrayVec of subproperties, contains space for the longest shorthand except all.

Aliased Type§

struct SubpropertiesVec<T> { /* private fields */ }

Implementations

source§

impl<T, const CAP: usize> ArrayVec<T, CAP>

source

pub fn new() -> ArrayVec<T, CAP>

Create a new empty ArrayVec.

The maximum capacity is given by the generic parameter CAP.

use arrayvec::ArrayVec;

let mut array = ArrayVec::<_, 16>::new();
array.push(1);
array.push(2);
assert_eq!(&array[..], &[1, 2]);
assert_eq!(array.capacity(), 16);
source

pub const fn new_const() -> ArrayVec<T, CAP>

Create a new empty ArrayVec (const fn).

The maximum capacity is given by the generic parameter CAP.

use arrayvec::ArrayVec;

static ARRAY: ArrayVec<u8, 1024> = ArrayVec::new_const();
source

pub const fn len(&self) -> usize

Return the number of elements in the ArrayVec.

use arrayvec::ArrayVec;

let mut array = ArrayVec::from([1, 2, 3]);
array.pop();
assert_eq!(array.len(), 2);
source

pub const fn is_empty(&self) -> bool

Returns whether the ArrayVec is empty.

use arrayvec::ArrayVec;

let mut array = ArrayVec::from([1]);
array.pop();
assert_eq!(array.is_empty(), true);
source

pub const fn capacity(&self) -> usize

Return the capacity of the ArrayVec.

use arrayvec::ArrayVec;

let array = ArrayVec::from([1, 2, 3]);
assert_eq!(array.capacity(), 3);
source

pub const fn is_full(&self) -> bool

Return true if the ArrayVec is completely filled to its capacity, false otherwise.

use arrayvec::ArrayVec;

let mut array = ArrayVec::<_, 1>::new();
assert!(!array.is_full());
array.push(1);
assert!(array.is_full());
source

pub const fn remaining_capacity(&self) -> usize

Returns the capacity left in the ArrayVec.

use arrayvec::ArrayVec;

let mut array = ArrayVec::from([1, 2, 3]);
array.pop();
assert_eq!(array.remaining_capacity(), 1);
source

pub fn push(&mut self, element: T)

Push element to the end of the vector.

Panics if the vector is already full.

use arrayvec::ArrayVec;

let mut array = ArrayVec::<_, 2>::new();

array.push(1);
array.push(2);

assert_eq!(&array[..], &[1, 2]);
source

pub fn try_push(&mut self, element: T) -> Result<(), CapacityError<T>>

Push element to the end of the vector.

Return Ok if the push succeeds, or return an error if the vector is already full.

use arrayvec::ArrayVec;

let mut array = ArrayVec::<_, 2>::new();

let push1 = array.try_push(1);
let push2 = array.try_push(2);

assert!(push1.is_ok());
assert!(push2.is_ok());

assert_eq!(&array[..], &[1, 2]);

let overflow = array.try_push(3);

assert!(overflow.is_err());
source

pub unsafe fn push_unchecked(&mut self, element: T)

Push element to the end of the vector without checking the capacity.

It is up to the caller to ensure the capacity of the vector is sufficiently large.

This method uses debug assertions to check that the arrayvec is not full.

use arrayvec::ArrayVec;

let mut array = ArrayVec::<_, 2>::new();

if array.len() + 2 <= array.capacity() {
    unsafe {
        array.push_unchecked(1);
        array.push_unchecked(2);
    }
}

assert_eq!(&array[..], &[1, 2]);
source

pub fn truncate(&mut self, new_len: usize)

Shortens the vector, keeping the first len elements and dropping the rest.

If len is greater than the vector’s current length this has no effect.

use arrayvec::ArrayVec;

let mut array = ArrayVec::from([1, 2, 3, 4, 5]);
array.truncate(3);
assert_eq!(&array[..], &[1, 2, 3]);
array.truncate(4);
assert_eq!(&array[..], &[1, 2, 3]);
source

pub fn clear(&mut self)

Remove all elements in the vector.

source

pub fn insert(&mut self, index: usize, element: T)

Insert element at position index.

Shift up all elements after index.

It is an error if the index is greater than the length or if the arrayvec is full.

Panics if the array is full or the index is out of bounds. See try_insert for fallible version.

use arrayvec::ArrayVec;

let mut array = ArrayVec::<_, 2>::new();

array.insert(0, "x");
array.insert(0, "y");
assert_eq!(&array[..], &["y", "x"]);
source

pub fn try_insert( &mut self, index: usize, element: T, ) -> Result<(), CapacityError<T>>

Insert element at position index.

Shift up all elements after index; the index must be less than or equal to the length.

Returns an error if vector is already at full capacity.

Panics index is out of bounds.

use arrayvec::ArrayVec;

let mut array = ArrayVec::<_, 2>::new();

assert!(array.try_insert(0, "x").is_ok());
assert!(array.try_insert(0, "y").is_ok());
assert!(array.try_insert(0, "z").is_err());
assert_eq!(&array[..], &["y", "x"]);
source

pub fn pop(&mut self) -> Option<T>

Remove the last element in the vector and return it.

Return Some( element ) if the vector is non-empty, else None.

use arrayvec::ArrayVec;

let mut array = ArrayVec::<_, 2>::new();

array.push(1);

assert_eq!(array.pop(), Some(1));
assert_eq!(array.pop(), None);
source

pub fn swap_remove(&mut self, index: usize) -> T

Remove the element at index and swap the last element into its place.

This operation is O(1).

Return the element if the index is in bounds, else panic.

Panics if the index is out of bounds.

use arrayvec::ArrayVec;

let mut array = ArrayVec::from([1, 2, 3]);

assert_eq!(array.swap_remove(0), 1);
assert_eq!(&array[..], &[3, 2]);

assert_eq!(array.swap_remove(1), 2);
assert_eq!(&array[..], &[3]);
source

pub fn swap_pop(&mut self, index: usize) -> Option<T>

Remove the element at index and swap the last element into its place.

This is a checked version of .swap_remove.
This operation is O(1).

Return Some( element ) if the index is in bounds, else None.

use arrayvec::ArrayVec;

let mut array = ArrayVec::from([1, 2, 3]);

assert_eq!(array.swap_pop(0), Some(1));
assert_eq!(&array[..], &[3, 2]);

assert_eq!(array.swap_pop(10), None);
source

pub fn remove(&mut self, index: usize) -> T

Remove the element at index and shift down the following elements.

The index must be strictly less than the length of the vector.

Panics if the index is out of bounds.

use arrayvec::ArrayVec;

let mut array = ArrayVec::from([1, 2, 3]);

let removed_elt = array.remove(0);
assert_eq!(removed_elt, 1);
assert_eq!(&array[..], &[2, 3]);
source

pub fn pop_at(&mut self, index: usize) -> Option<T>

Remove the element at index and shift down the following elements.

This is a checked version of .remove(index). Returns None if there is no element at index. Otherwise, return the element inside Some.

use arrayvec::ArrayVec;

let mut array = ArrayVec::from([1, 2, 3]);

assert!(array.pop_at(0).is_some());
assert_eq!(&array[..], &[2, 3]);

assert!(array.pop_at(2).is_none());
assert!(array.pop_at(10).is_none());
source

pub fn retain<F>(&mut self, f: F)
where F: FnMut(&mut T) -> bool,

Retains only the elements specified by the predicate.

In other words, remove all elements e such that f(&mut e) returns false. This method operates in place and preserves the order of the retained elements.

use arrayvec::ArrayVec;

let mut array = ArrayVec::from([1, 2, 3, 4]);
array.retain(|x| *x & 1 != 0 );
assert_eq!(&array[..], &[1, 3]);
source

pub unsafe fn set_len(&mut self, length: usize)

Set the vector’s length without dropping or moving out elements

This method is unsafe because it changes the notion of the number of “valid” elements in the vector. Use with care.

This method uses debug assertions to check that length is not greater than the capacity.

source

pub fn try_extend_from_slice( &mut self, other: &[T], ) -> Result<(), CapacityError>
where T: Copy,

Copy all elements from the slice and append to the ArrayVec.

use arrayvec::ArrayVec;

let mut vec: ArrayVec<usize, 10> = ArrayVec::new();
vec.push(1);
vec.try_extend_from_slice(&[2, 3]).unwrap();
assert_eq!(&vec[..], &[1, 2, 3]);
§Errors

This method will return an error if the capacity left (see remaining_capacity) is smaller then the length of the provided slice.

source

pub fn drain<R>(&mut self, range: R) -> Drain<'_, T, CAP>
where R: RangeBounds<usize>,

Create a draining iterator that removes the specified range in the vector and yields the removed items from start to end. The element range is removed even if the iterator is not consumed until the end.

Note: It is unspecified how many elements are removed from the vector, if the Drain value is leaked.

Panics if the starting point is greater than the end point or if the end point is greater than the length of the vector.

use arrayvec::ArrayVec;

let mut v1 = ArrayVec::from([1, 2, 3]);
let v2: ArrayVec<_, 3> = v1.drain(0..2).collect();
assert_eq!(&v1[..], &[3]);
assert_eq!(&v2[..], &[1, 2]);
source

pub fn into_inner(self) -> Result<[T; CAP], ArrayVec<T, CAP>>

Return the inner fixed size array, if it is full to its capacity.

Return an Ok value with the array if length equals capacity, return an Err with self otherwise.

source

pub unsafe fn into_inner_unchecked(self) -> [T; CAP]

Return the inner fixed size array.

Safety: This operation is safe if and only if length equals capacity.

source

pub fn take(&mut self) -> ArrayVec<T, CAP>

Returns the ArrayVec, replacing the original with a new empty ArrayVec.

use arrayvec::ArrayVec;

let mut v = ArrayVec::from([0, 1, 2, 3]);
assert_eq!([0, 1, 2, 3], v.take().into_inner().unwrap());
assert!(v.is_empty());
source

pub fn as_slice(&self) -> &[T]

Return a slice containing all elements of the vector.

source

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

Return a mutable slice containing all elements of the vector.

source

pub fn as_ptr(&self) -> *const T

Return a raw pointer to the vector’s buffer.

source

pub fn as_mut_ptr(&mut self) -> *mut T

Return a raw mutable pointer to the vector’s buffer.

Trait Implementations

source§

impl<T, const CAP: usize> AsMut<[T]> for ArrayVec<T, CAP>

source§

fn as_mut(&mut self) -> &mut [T]

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl<T, const CAP: usize> AsRef<[T]> for ArrayVec<T, CAP>

source§

fn as_ref(&self) -> &[T]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<T, const CAP: usize> Borrow<[T]> for ArrayVec<T, CAP>

source§

fn borrow(&self) -> &[T]

Immutably borrows from an owned value. Read more
source§

impl<T, const CAP: usize> BorrowMut<[T]> for ArrayVec<T, CAP>

source§

fn borrow_mut(&mut self) -> &mut [T]

Mutably borrows from an owned value. Read more
source§

impl<T, const CAP: usize> Clone for ArrayVec<T, CAP>
where T: Clone,

source§

fn clone(&self) -> ArrayVec<T, CAP>

Returns a copy of the value. Read more
source§

fn clone_from(&mut self, rhs: &ArrayVec<T, CAP>)

Performs copy-assignment from source. Read more
source§

impl<T, const CAP: usize> Debug for ArrayVec<T, CAP>
where T: Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<T, const CAP: usize> Default for ArrayVec<T, CAP>

source§

fn default() -> ArrayVec<T, CAP>

Return an empty array

source§

impl<T, const CAP: usize> DerefMut for ArrayVec<T, CAP>

source§

fn deref_mut(&mut self) -> &mut <ArrayVec<T, CAP> as Deref>::Target

Mutably dereferences the value.
source§

impl<'de, T, const CAP: usize> Deserialize<'de> for ArrayVec<T, CAP>
where T: Deserialize<'de>,

Requires crate feature "serde"

source§

fn deserialize<D>( deserializer: D, ) -> Result<ArrayVec<T, CAP>, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<T, const CAP: usize> Drop for ArrayVec<T, CAP>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<T, const CAP: usize> Extend<T> for ArrayVec<T, CAP>

Extend the ArrayVec with an iterator.

Panics if extending the vector exceeds its capacity.

source§

fn extend<I>(&mut self, iter: I)
where I: IntoIterator<Item = T>,

Extend the ArrayVec with an iterator.

Panics if extending the vector exceeds its capacity.

source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl<T, const CAP: usize> From<[T; CAP]> for ArrayVec<T, CAP>

Create an ArrayVec from an array.

use arrayvec::ArrayVec;

let mut array = ArrayVec::from([1, 2, 3]);
assert_eq!(array.len(), 3);
assert_eq!(array.capacity(), 3);
source§

fn from(array: [T; CAP]) -> ArrayVec<T, CAP>

Converts to this type from the input type.
source§

impl<T, const CAP: usize> FromIterator<T> for ArrayVec<T, CAP>

Create an ArrayVec from an iterator.

Panics if the number of elements in the iterator exceeds the arrayvec’s capacity.

source§

fn from_iter<I>(iter: I) -> ArrayVec<T, CAP>
where I: IntoIterator<Item = T>,

Create an ArrayVec from an iterator.

Panics if the number of elements in the iterator exceeds the arrayvec’s capacity.

source§

impl<T, const CAP: usize> Hash for ArrayVec<T, CAP>
where T: Hash,

source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<T, const CAP: usize> IntoIterator for ArrayVec<T, CAP>

Iterate the ArrayVec with each element by value.

The vector is consumed by this operation.

use arrayvec::ArrayVec;

for elt in ArrayVec::from([1, 2, 3]) {
    // ...
}
source§

type Item = T

The type of the elements being iterated over.
source§

type IntoIter = IntoIter<T, CAP>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> IntoIter<T, CAP>

Creates an iterator from a value. Read more
source§

impl<T, const CAP: usize> Ord for ArrayVec<T, CAP>
where T: Ord,

source§

fn cmp(&self, other: &ArrayVec<T, CAP>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
source§

impl<T, const CAP: usize> PartialEq<[T]> for ArrayVec<T, CAP>
where T: PartialEq,

source§

fn eq(&self, other: &[T]) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T, const CAP: usize> PartialEq for ArrayVec<T, CAP>
where T: PartialEq,

source§

fn eq(&self, other: &ArrayVec<T, CAP>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T, const CAP: usize> PartialOrd for ArrayVec<T, CAP>
where T: PartialOrd,

source§

fn partial_cmp(&self, other: &ArrayVec<T, CAP>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
source§

fn lt(&self, other: &ArrayVec<T, CAP>) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
source§

fn le(&self, other: &ArrayVec<T, CAP>) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
source§

fn ge(&self, other: &ArrayVec<T, CAP>) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

fn gt(&self, other: &ArrayVec<T, CAP>) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
source§

impl<T, const CAP: usize> Serialize for ArrayVec<T, CAP>
where T: Serialize,

Requires crate feature "serde"

source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<T, const CAP: usize> TryFrom<&[T]> for ArrayVec<T, CAP>
where T: Clone,

Try to create an ArrayVec from a slice. This will return an error if the slice was too big to fit.

use arrayvec::ArrayVec;
use std::convert::TryInto as _;

let array: ArrayVec<_, 4> = (&[1, 2, 3] as &[_]).try_into().unwrap();
assert_eq!(array.len(), 3);
assert_eq!(array.capacity(), 4);
source§

type Error = CapacityError

The type returned in the event of a conversion error.
source§

fn try_from( slice: &[T], ) -> Result<ArrayVec<T, CAP>, <ArrayVec<T, CAP> as TryFrom<&[T]>>::Error>

Performs the conversion.
source§

impl<const CAP: usize> Write for ArrayVec<u8, CAP>

Write appends written data to the end of the vector.

Requires features="std".

source§

fn write(&mut self, data: &[u8]) -> Result<usize, Error>

Writes a buffer into this writer, returning how many bytes were written. Read more
source§

fn flush(&mut self) -> Result<(), Error>

Flushes this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
1.36.0 · source§

fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize, Error>

Like write, except that it writes from a slice of buffers. Read more
source§

fn is_write_vectored(&self) -> bool

🔬This is a nightly-only experimental API. (can_vector)
Determines if this Writer has an efficient write_vectored implementation. Read more
1.0.0 · source§

fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>

Attempts to write an entire buffer into this writer. Read more
source§

fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>

🔬This is a nightly-only experimental API. (write_all_vectored)
Attempts to write multiple buffers into this writer. Read more
1.0.0 · source§

fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<(), Error>

Writes a formatted string into this writer, returning any error encountered. Read more
1.0.0 · source§

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Creates a “by reference” adapter for this instance of Write. Read more
source§

impl<T, const CAP: usize> Deref for ArrayVec<T, CAP>

source§

type Target = [T]

The resulting type after dereferencing.
source§

fn deref(&self) -> &<ArrayVec<T, CAP> as Deref>::Target

Dereferences the value.
source§

impl<T, const CAP: usize> Eq for ArrayVec<T, CAP>
where T: Eq,