hcl_edit::expr

Struct Object

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

Type representing a HCL object.

Implementations§

Source§

impl Object

Source

pub fn new() -> Self

Constructs a new, empty Object.

Source

pub fn with_capacity(capacity: usize) -> Self

Constructs a new, empty Object with at least the specified capacity.

Source

pub fn is_empty(&self) -> bool

Returns true if the object contains no items.

Source

pub fn len(&self) -> usize

Returns the number of items in the object, also referred to as its ‘length’.

Source

pub fn clear(&mut self)

Clears the object, removing all items.

Source

pub fn contains_key(&self, key: &ObjectKey) -> bool

Return true if an equivalent to key exists in the object.

Source

pub fn get(&self, key: &ObjectKey) -> Option<&ObjectValue>

Return a reference to the value stored for key, if it is present, else None.

Source

pub fn get_mut(&mut self, key: &ObjectKey) -> Option<&mut ObjectValue>

Return a mutable reference to the value stored for key, if it is present, else None.

Source

pub fn get_key_value( &self, key: &ObjectKey, ) -> Option<(&ObjectKey, &ObjectValue)>

Return references to the key-value pair stored for key, if it is present, else None.

Source

pub fn get_key_value_mut<'a>( &'a mut self, key: &ObjectKey, ) -> Option<(ObjectKeyMut<'a>, &'a mut ObjectValue)>

Return mutable references to the key-value pair stored for key, if it is present, else None.

Source

pub fn insert( &mut self, key: impl Into<ObjectKey>, value: impl Into<ObjectValue>, ) -> Option<ObjectValue>

Insert a key-value pair into the object.

If an equivalent key already exists in the object: the key remains and retains in its place in the order, its corresponding value is updated with value and the older value is returned inside Some(_).

If no equivalent key existed in the object: the new key-value pair is inserted, last in order, and None is returned.

Source

pub fn remove(&mut self, key: &ObjectKey) -> Option<ObjectValue>

Remove the key-value pair equivalent to key and return its value.

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

Source

pub fn remove_entry( &mut self, key: &ObjectKey, ) -> Option<(ObjectKey, ObjectValue)>

Remove and return the key-value pair equivalent to key.

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

Source

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

An iterator visiting all key-value pairs in insertion order. The iterator element type is (&'a ObjectKey, &'a ObjectValue).

Source

pub fn iter_mut(&mut self) -> ObjectIterMut<'_>

An iterator visiting all key-value pairs in insertion order, with mutable references to the values. The iterator element type is (ObjectKeyMut<'a>, &'a mut ObjectValue).

Source

pub fn trailing(&self) -> &RawString

Return a reference to raw trailing decor before the object’s closing }.

Source

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

Set the raw trailing decor before the object’s closing }.

Trait Implementations§

Source§

impl Clone for Object

Source§

fn clone(&self) -> Object

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 Object

Source§

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

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

impl Decorate for Object

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 Object

Source§

fn default() -> Object

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

impl<K, V> Extend<(K, V)> for Object
where K: Into<ObjectKey>, V: Into<ObjectValue>,

Source§

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

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<Object> for Expression

Source§

fn from(value: Object) -> Self

Converts to this type from the input type.
Source§

impl From<VecMap<ObjectKey, ObjectValue>> for Object

Source§

fn from(items: VecMap<ObjectKey, ObjectValue>) -> Self

Converts to this type from the input type.
Source§

impl<K, V> FromIterator<(K, V)> for Object
where K: Into<ObjectKey>, V: Into<ObjectValue>,

Source§

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

Creates a value from an iterator. Read more
Source§

impl<'a> IntoIterator for &'a Object

Source§

type Item = (&'a ObjectKey, &'a ObjectValue)

The type of the elements being iterated over.
Source§

type IntoIter = Box<dyn Iterator<Item = (&'a ObjectKey, &'a ObjectValue)> + '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 Object

Source§

type Item = (ObjectKeyMut<'a>, &'a mut ObjectValue)

The type of the elements being iterated over.
Source§

type IntoIter = Box<dyn Iterator<Item = (ObjectKeyMut<'a>, &'a mut ObjectValue)> + '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 Object

Source§

type Item = (ObjectKey, ObjectValue)

The type of the elements being iterated over.
Source§

type IntoIter = Box<dyn Iterator<Item = (ObjectKey, ObjectValue)>>

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 Object

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 Object

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 Object

Auto Trait Implementations§

§

impl Freeze for Object

§

impl RefUnwindSafe for Object

§

impl Send for Object

§

impl Sync for Object

§

impl Unpin for Object

§

impl UnwindSafe for Object

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.