pub struct Array { /* private fields */ }Expand description
Type representing a HCL array.
Implementations§
source§impl Array
 
impl Array
sourcepub fn with_capacity(capacity: usize) -> Self
 
pub fn with_capacity(capacity: usize) -> Self
Constructs a new, empty Array with at least the specified capacity.
sourcepub fn len(&self) -> usize
 
pub fn len(&self) -> usize
Returns the number of elements in the array, also referred to as its ‘length’.
sourcepub fn get(&self, index: usize) -> Option<&Expression>
 
pub fn get(&self, index: usize) -> Option<&Expression>
Returns a reference to the value at the given index, or None if the index is out of
bounds.
sourcepub fn get_mut(&mut self, index: usize) -> Option<&mut Expression>
 
pub fn get_mut(&mut self, index: usize) -> Option<&mut Expression>
Returns a mutable reference to the value at the given index, or None if the index is out
of bounds.
sourcepub fn insert(&mut self, index: usize, value: impl Into<Expression>)
 
pub fn insert(&mut self, index: usize, value: impl Into<Expression>)
Inserts an element at position index within the array, shifting all elements after it to
the right.
§Panics
Panics if index > len.
sourcepub fn push(&mut self, value: impl Into<Expression>)
 
pub fn push(&mut self, value: impl Into<Expression>)
Appends an element to the back of the array.
§Panics
Panics if the new capacity exceeds isize::MAX bytes.
sourcepub fn pop(&mut self) -> Option<Expression>
 
pub fn pop(&mut self) -> Option<Expression>
Removes the last element from the array and returns it, or None if it is empty.
sourcepub fn remove(&mut self, index: usize) -> Expression
 
pub fn remove(&mut self, index: usize) -> Expression
Removes and returns the element at position index within the array, shifting all elements
after it to the left.
Like Vec::remove, the element is removed by shifting all of the elements that follow it,
preserving their relative order. This perturbs the index of all of those elements!
§Panics
Panics if index is out of bounds.
sourcepub fn iter(&self) -> Iter<'_>
 
pub fn iter(&self) -> Iter<'_>
An iterator visiting all values in insertion order. The iterator element type is &'a Expression.
sourcepub fn iter_mut(&mut self) -> IterMut<'_>
 
pub fn iter_mut(&mut self) -> IterMut<'_>
An iterator visiting all values in insertion order, with mutable references to the values.
The iterator element type is &'a mut Expression.
sourcepub fn trailing(&self) -> &RawString
 
pub fn trailing(&self) -> &RawString
Return a reference to raw trailing decor before the array’s closing ].
sourcepub fn set_trailing(&mut self, trailing: impl Into<RawString>)
 
pub fn set_trailing(&mut self, trailing: impl Into<RawString>)
Set the raw trailing decor before the array’s closing ].
sourcepub fn trailing_comma(&self) -> bool
 
pub fn trailing_comma(&self) -> bool
Returns true if the array uses a trailing comma.
sourcepub fn set_trailing_comma(&mut self, yes: bool)
 
pub fn set_trailing_comma(&mut self, yes: bool)
Set whether the array will use a trailing comma.
Trait Implementations§
source§impl<T> Extend<T> for Arraywhere
    T: Into<Expression>,
 
impl<T> Extend<T> for Arraywhere
    T: Into<Expression>,
source§fn extend<I>(&mut self, iterable: I)where
    I: IntoIterator<Item = T>,
 
fn extend<I>(&mut self, iterable: I)where
    I: IntoIterator<Item = T>,
source§fn extend_one(&mut self, item: A)
 
fn extend_one(&mut self, item: A)
extend_one)source§fn extend_reserve(&mut self, additional: usize)
 
fn extend_reserve(&mut self, additional: usize)
extend_one)source§impl From<Array> for Expression
 
impl From<Array> for Expression
source§impl From<Vec<Expression>> for Array
 
impl From<Vec<Expression>> for Array
source§fn from(values: Vec<Expression>) -> Self
 
fn from(values: Vec<Expression>) -> Self
source§impl<T> FromIterator<T> for Arraywhere
    T: Into<Expression>,
 
impl<T> FromIterator<T> for Arraywhere
    T: Into<Expression>,
source§fn from_iter<I>(iterable: I) -> Selfwhere
    I: IntoIterator<Item = T>,
 
fn from_iter<I>(iterable: I) -> Selfwhere
    I: IntoIterator<Item = T>,
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
impl Eq 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
source§impl<T> CloneToUninit for Twhere
    T: Clone,
 
impl<T> CloneToUninit for Twhere
    T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
 
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)