Struct hcl_edit::expr::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>) -> Selfwhere 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 Objectwhere 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 Objectwhere K: Into<ObjectKey>, V: Into<ObjectValue>,

source§

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

Creates a value from an iterator. Read more
source§

impl<'a> IntoIterator for &'a Object

§

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

The type of the elements being iterated over.
§

type IntoIter = Box<dyn Iterator<Item = (&'a ObjectKey, &'a ObjectValue)> + 'a, Global>

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

§

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

The type of the elements being iterated over.
§

type IntoIter = Box<dyn Iterator<Item = (ObjectKeyMut<'a>, &'a mut ObjectValue)> + 'a, Global>

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

§

type Item = (ObjectKey, ObjectValue)

The type of the elements being iterated over.
§

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

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

source§

fn eq(&self, other: &Self) -> bool

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

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

This method 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

source§

impl StructuralEq for Object

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.