Struct Properties

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

Map of property names to property values.

It features O(log n) lookup and preserves insertion order, as well as convenience methods for type-safe access and parsing of values.

This structure is case-sensitive. It’s the caller’s responsibility to ensure all keys and values are lowercased.

Implementations§

Source§

impl Properties

Source

pub const fn new() -> Properties

Constructs a new empty Properties.

Source

pub fn len(&self) -> usize

Returns the number of key-value pairs, including those with empty values.

Source

pub fn is_empty(&self) -> bool

Returns true if self contains no key-value pairs.

Source

pub fn get_raw_for_key(&self, key: impl AsRef<str>) -> &RawValue

Returns the unparsed “raw” value for the specified key.

Does not test for the “unset” value. Use RawValue::filter_unset.

Source

pub fn get_raw<T: PropertyKey>(&self) -> &RawValue

Returns the unparsed “raw” value for the specified property.

Does not test for the “unset” value. Use RawValue::filter_unset.

Source

pub fn get<T: PropertyKey + PropertyValue>(&self) -> Result<T, &RawValue>

Returns the parsed value for the specified property.

Does not test for the “unset” value if parsing fails. Use RawValue::filter_unset.

Source

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

Returns an iterator over the key-value pairs.

If the allow-empty-values feature is NOT used, key-value pairs where the value is empty will be skipped. Otherwise, they will be returned as normal.

Pairs are returned from oldest to newest.

Source

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

Returns an iterator over the key-value pairs that allows mutation of the values.

If the allow-empty-values feature is NOT used, key-value pairs where the value is empty will be skipped. Otherwise, they will be returned as normal.

Pairs are returned from oldest to newest.

Source

pub fn insert_raw_for_key( &mut self, key: impl AsRef<str>, val: impl Into<RawValue>, )

Sets the value for a specified key.

Source

pub fn insert_raw<K: PropertyKey, V: Into<RawValue>>(&mut self, val: V)

Sets the value for a specified property’s key.

Source

pub fn insert<T: PropertyKey + Into<RawValue>>(&mut self, prop: T)

Inserts a specified property into the map.

Source

pub fn try_insert_raw_for_key( &mut self, key: impl AsRef<str>, value: impl Into<RawValue>, ) -> Result<(), &mut RawValue>

Attempts to add a new key-value pair to the map.

If the key was already associated with a value, returns a mutable reference to the old value and does not update the map.

Source

pub fn try_insert_raw<K: PropertyKey, V: Into<RawValue>>( &mut self, val: V, ) -> Result<(), &mut RawValue>

Attempts to add a new property to the map with a specified value.

If the key was already associated with a value, returns a mutable reference to the old value and does not update the map.

Source

pub fn try_insert<T: PropertyKey + Into<RawValue>>( &mut self, prop: T, ) -> Result<(), &mut RawValue>

Attempts to add a new property to the map.

If the key was already associated with a value, returns a mutable reference to the old value and does not update the map.

Source

pub fn use_fallbacks(&mut self)

Adds fallback values for certain common key-value pairs.

Used to obtain spec-compliant values for crate::property::IndentSize and crate::property::TabWidth.

Source

pub fn use_fallbacks_legacy(&mut self)

Adds pre-0.9.0 fallback values for certain common key-value pairs.

This shouldn’t be used outside of narrow cases where compatibility with those older standards is required. Prefer Properties::use_fallbacks instead.

Trait Implementations§

Source§

impl Clone for Properties

Source§

fn clone(&self) -> Properties

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 Properties

Source§

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

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

impl Default for Properties

Source§

fn default() -> Properties

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

impl<K: AsRef<str>, V: Into<RawValue>> Extend<(K, V)> for Properties

Source§

fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: 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<K: AsRef<str>, V: Into<RawValue>> FromIterator<(K, V)> for Properties

Source§

fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl<'a> IntoIterator for &'a Properties

Source§

type Item = <Iter<'a> as Iterator>::Item

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'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 Properties

Source§

type Item = <IterMut<'a> as Iterator>::Item

The type of the elements being iterated over.
Source§

type IntoIter = IterMut<'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 PartialEq for Properties

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<'a> PropertiesSource for &'a Properties

Source§

fn apply_to( self, props: &mut Properties, _: impl AsRef<Path>, ) -> Result<(), Error>

Adds properties that apply to a file at the specified path to the provided Properties.
Source§

impl Eq for Properties

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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.