hcl_edit::expr

Struct FuncArgs

Source
pub struct FuncArgs { /* private fields */ }
Expand description

Type representing the arguments of a function call.

In the HCL grammar, function arguments are delimited by ( and ).

Implementations§

Source§

impl FuncArgs

Source

pub fn new() -> Self

Constructs new, empty FuncArgs.

Source

pub fn with_capacity(capacity: usize) -> Self

Constructs new, empty FuncArgs with at least the specified capacity.

Source

pub fn is_empty(&self) -> bool

Returns true if the function arguments are empty.

Source

pub fn len(&self) -> usize

Returns the number of function arguments, also referred to as its ‘length’.

Source

pub fn clear(&mut self)

Clears the function arguments.

Source

pub fn get(&self, index: usize) -> Option<&Expression>

Returns a reference to the argument at the given index, or None if the index is out of bounds.

Source

pub fn get_mut(&mut self, index: usize) -> Option<&mut Expression>

Returns a mutable reference to the argument at the given index, or None if the index is out of bounds.

Source

pub fn insert(&mut self, index: usize, arg: impl Into<Expression>)

Inserts an argument at position index, shifting all arguments after it to the right.

§Panics

Panics if index > len.

Source

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

Removes the last argument and returns it, or None if it is empty.

Source

pub fn push(&mut self, arg: impl Into<Expression>)

Appends an argument.

§Panics

Panics if the new capacity exceeds isize::MAX bytes.

Source

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

Removes and returns the argument at position index, shifting all arguments after it to the left.

Like Vec::remove, the argument is removed by shifting all of the arguments that follow it, preserving their relative order. This perturbs the index of all of those elements!

§Panics

Panics if index is out of bounds.

Source

pub fn iter(&self) -> Iter<'_>

An iterator visiting all values in insertion order. The iterator element type is &'a Expression.

Source

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.

Source

pub fn expand_final(&self) -> bool

Returns true if the final argument is a ... list expansion.

Source

pub fn set_expand_final(&mut self, yes: bool)

Set whether the final argument should be a ... list expansion.

Source

pub fn trailing(&self) -> &RawString

Return a reference to raw trailing decor before the function argument’s closing ).

Source

pub fn set_trailing(&mut self, trailing: impl Into<RawString>)

Set the raw trailing decor before the function argument’s closing ).

Source

pub fn trailing_comma(&self) -> bool

Returns true if the function arguments use a trailing comma.

Source

pub fn set_trailing_comma(&mut self, yes: bool)

Set whether the function arguments will use a trailing comma.

Trait Implementations§

Source§

impl Clone for FuncArgs

Source§

fn clone(&self) -> FuncArgs

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FuncArgs

Source§

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

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

impl Decorate for FuncArgs

Source§

fn decor(&self) -> &Decor

Returns a reference to the object’s Decor.
Source§

fn decor_mut(&mut self) -> &mut Decor

Returns a mutable reference to the object’s Decor.
Source§

fn decorate(&mut self, decor: impl Into<Decor>)

Decorate the object with decor in-place.
Source§

fn decorated(self, decor: impl Into<Decor>) -> Self
where Self: Sized,

Decorate the object with decor and return the modified value.
Source§

impl Default for FuncArgs

Source§

fn default() -> FuncArgs

Returns the “default value” for a type. Read more
Source§

impl<T> Extend<T> for FuncArgs
where T: Into<Expression>,

Source§

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

Extends a collection with the contents of an iterator. Read more
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 From<Vec<Expression>> for FuncArgs

Source§

fn from(args: Vec<Expression>) -> Self

Converts to this type from the input type.
Source§

impl<T> FromIterator<T> for FuncArgs
where T: Into<Expression>,

Source§

fn from_iter<I>(iterable: I) -> Self
where I: IntoIterator<Item = T>,

Creates a value from an iterator. Read more
Source§

impl<'a> IntoIterator for &'a FuncArgs

Source§

type Item = &'a Expression

The type of the elements being iterated over.
Source§

type IntoIter = Box<dyn Iterator<Item = &'a Expression> + 'a>

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

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a> IntoIterator for &'a mut FuncArgs

Source§

type Item = &'a mut Expression

The type of the elements being iterated over.
Source§

type IntoIter = Box<dyn Iterator<Item = &'a mut Expression> + 'a>

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

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl IntoIterator for FuncArgs

Source§

type Item = Expression

The type of the elements being iterated over.
Source§

type IntoIter = Box<dyn Iterator<Item = Expression>>

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

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for FuncArgs

Source§

fn eq(&self, other: &Self) -> 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 Span for FuncArgs

Source§

fn span(&self) -> Option<Range<usize>>

Obtains the span information. This only returns Some if the value was emitted by the parser. Read more
Source§

impl Eq for FuncArgs

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

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

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.