Struct Attributes

Source
pub struct Attributes(/* private fields */);

Implementations§

Source§

impl Attributes

Source

pub fn with_defaults<I: Into<Attributes>>(self, defaults: I) -> Attributes

Methods from Deref<Target = Option<HashMap<AttrValue, Option<AttrValue>>>>§

1.0.0 · Source

pub fn is_some(&self) -> bool

Returns true if the option is a Some value.

§Examples
let x: Option<u32> = Some(2);
assert_eq!(x.is_some(), true);

let x: Option<u32> = None;
assert_eq!(x.is_some(), false);
1.0.0 · Source

pub fn is_none(&self) -> bool

Returns true if the option is a None value.

§Examples
let x: Option<u32> = Some(2);
assert_eq!(x.is_none(), false);

let x: Option<u32> = None;
assert_eq!(x.is_none(), true);
1.0.0 · Source

pub fn as_ref(&self) -> Option<&T>

Converts from &Option<T> to Option<&T>.

§Examples

Calculates the length of an Option<String> as an Option<usize> without moving the String. The map method takes the self argument by value, consuming the original, so this technique uses as_ref to first take an Option to a reference to the value inside the original.

let text: Option<String> = Some("Hello, world!".to_string());
// First, cast `Option<String>` to `Option<&String>` with `as_ref`,
// then consume *that* with `map`, leaving `text` on the stack.
let text_length: Option<usize> = text.as_ref().map(|s| s.len());
println!("still can print text: {text:?}");
1.33.0 · Source

pub fn as_pin_ref(self: Pin<&Option<T>>) -> Option<Pin<&T>>

Converts from Pin<&Option<T>> to Option<Pin<&T>>.

1.33.0 · Source

pub fn as_pin_mut(self: Pin<&mut Option<T>>) -> Option<Pin<&mut T>>

Converts from Pin<&mut Option<T>> to Option<Pin<&mut T>>.

1.75.0 · Source

pub fn as_slice(&self) -> &[T]

Returns a slice of the contained value, if any. If this is None, an empty slice is returned. This can be useful to have a single type of iterator over an Option or slice.

Note: Should you have an Option<&T> and wish to get a slice of T, you can unpack it via opt.map_or(&[], std::slice::from_ref).

§Examples
assert_eq!(
    [Some(1234).as_slice(), None.as_slice()],
    [&[1234][..], &[][..]],
);

The inverse of this function is (discounting borrowing) [_]::first:

for i in [Some(1234_u16), None] {
    assert_eq!(i.as_ref(), i.as_slice().first());
}
1.40.0 · Source

pub fn as_deref(&self) -> Option<&<T as Deref>::Target>
where T: Deref,

Converts from Option<T> (or &Option<T>) to Option<&T::Target>.

Leaves the original Option in-place, creating a new one with a reference to the original one, additionally coercing the contents via Deref.

§Examples
let x: Option<String> = Some("hey".to_owned());
assert_eq!(x.as_deref(), Some("hey"));

let x: Option<String> = None;
assert_eq!(x.as_deref(), None);
1.0.0 · Source

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

Returns an iterator over the possibly contained value.

§Examples
let x = Some(4);
assert_eq!(x.iter().next(), Some(&4));

let x: Option<u32> = None;
assert_eq!(x.iter().next(), None);

Trait Implementations§

Source§

impl Clone for Attributes

Source§

fn clone(&self) -> Attributes

Returns a duplicate 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 Attributes

Source§

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

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

impl Default for Attributes

Source§

fn default() -> Attributes

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

impl Deref for Attributes

Source§

type Target = Option<HashMap<IString, Option<IString>>>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<const N: usize> From<[(&str, &str); N]> for Attributes

Source§

fn from(value: [(&str, &str); N]) -> Attributes

Converts to this type from the input type.
Source§

impl<const N: usize> From<[(&str, Option<&str>); N]> for Attributes

Source§

fn from(value: [(&str, Option<&str>); N]) -> Attributes

Converts to this type from the input type.
Source§

impl<const N: usize> From<[(&str, Option<String>); N]> for Attributes

Source§

fn from(value: [(&str, Option<String>); N]) -> Attributes

Converts to this type from the input type.
Source§

impl<const N: usize> From<[(&str, String); N]> for Attributes

Source§

fn from(value: [(&str, String); N]) -> Attributes

Converts to this type from the input type.
Source§

impl<const N: usize> From<[(IString, IString); N]> for Attributes

Source§

fn from(value: [(AttrValue, AttrValue); N]) -> Attributes

Converts to this type from the input type.
Source§

impl<const N: usize> From<[(IString, Option<IString>); N]> for Attributes

Source§

fn from(value: [(AttrValue, Option<AttrValue>); N]) -> Attributes

Converts to this type from the input type.
Source§

impl<const N: usize> From<[(String, Option<String>); N]> for Attributes

Source§

fn from(value: [(String, Option<String>); N]) -> Attributes

Converts to this type from the input type.
Source§

impl<const N: usize> From<[(String, String); N]> for Attributes

Source§

fn from(value: [(String, String); N]) -> Attributes

Converts to this type from the input type.
Source§

impl From<HashMap<IString, IString>> for Attributes

Source§

fn from(value: HashMap<AttrValue, AttrValue>) -> Attributes

Converts to this type from the input type.
Source§

impl From<HashMap<IString, Option<IString>>> for Attributes

Source§

fn from(value: HashMap<AttrValue, Option<AttrValue>>) -> Attributes

Converts to this type from the input type.
Source§

impl From<HashMap<String, Option<String>>> for Attributes

Source§

fn from(value: HashMap<String, Option<String>>) -> Attributes

Converts to this type from the input type.
Source§

impl From<HashMap<String, String>> for Attributes

Source§

fn from(value: HashMap<String, String>) -> Attributes

Converts to this type from the input type.
Source§

impl<'a> IntoIterator for &'a Attributes

Source§

type Item = &'a HashMap<IString, Option<IString>>

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, HashMap<IString, Option<IString>>>

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 Attributes

Source§

type Item = &'a mut HashMap<IString, Option<IString>>

The type of the elements being iterated over.
Source§

type IntoIter = IterMut<'a, HashMap<IString, Option<IString>>>

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 Attributes

Source§

type Item = HashMap<IString, Option<IString>>

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<HashMap<IString, Option<IString>>>

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<const N: usize> IntoPropValue<Attributes> for [(&str, &str); N]

Source§

fn into_prop_value(self) -> Attributes

Convert self to a value of a Properties struct.
Source§

impl<const N: usize> IntoPropValue<Attributes> for [(&str, Option<&str>); N]

Source§

fn into_prop_value(self) -> Attributes

Convert self to a value of a Properties struct.
Source§

impl<const N: usize> IntoPropValue<Attributes> for [(&str, Option<String>); N]

Source§

fn into_prop_value(self) -> Attributes

Convert self to a value of a Properties struct.
Source§

impl<const N: usize> IntoPropValue<Attributes> for [(&str, String); N]

Source§

fn into_prop_value(self) -> Attributes

Convert self to a value of a Properties struct.
Source§

impl<const N: usize> IntoPropValue<Attributes> for [(AttrValue, AttrValue); N]

Source§

fn into_prop_value(self) -> Attributes

Convert self to a value of a Properties struct.
Source§

impl<const N: usize> IntoPropValue<Attributes> for [(AttrValue, Option<AttrValue>); N]

Source§

fn into_prop_value(self) -> Attributes

Convert self to a value of a Properties struct.
Source§

impl<const N: usize> IntoPropValue<Attributes> for [(String, Option<String>); N]

Source§

fn into_prop_value(self) -> Attributes

Convert self to a value of a Properties struct.
Source§

impl<const N: usize> IntoPropValue<Attributes> for [(String, String); N]

Source§

fn into_prop_value(self) -> Attributes

Convert self to a value of a Properties struct.
Source§

impl IntoPropValue<Attributes> for HashMap<AttrValue, AttrValue>

Source§

fn into_prop_value(self) -> Attributes

Convert self to a value of a Properties struct.
Source§

impl IntoPropValue<Attributes> for HashMap<AttrValue, Option<AttrValue>>

Source§

fn into_prop_value(self) -> Attributes

Convert self to a value of a Properties struct.
Source§

impl IntoPropValue<Attributes> for HashMap<String, Option<String>>

Source§

fn into_prop_value(self) -> Attributes

Convert self to a value of a Properties struct.
Source§

impl IntoPropValue<Attributes> for HashMap<String, String>

Source§

fn into_prop_value(self) -> Attributes

Convert self to a value of a Properties struct.
Source§

impl PartialEq for Attributes

Source§

fn eq(&self, other: &Attributes) -> 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 StructuralPartialEq for Attributes

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoPropValue<Option<T>> for T

Source§

fn into_prop_value(self) -> Option<T>

Convert self to a value of a Properties struct.
Source§

impl<T> IntoPropValue<T> for T

Source§

fn into_prop_value(self) -> T

Convert self to a value of a Properties struct.
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<Token, Builder, How> AllPropsFor<Builder, How> for Token
where Builder: Buildable<Token>, <Builder as Buildable<Token>>::WrappedToken: HasAllProps<<Builder as Buildable<Token>>::Output, How>,

Source§

impl<T> HasAllProps<(), T> for T