Struct Args

Source
pub struct Args<'k> { /* private fields */ }
Expand description

This is an easy way to build an argument mapping for the template application method

The key must be a &str while the value can be any std::fmt::Display trait object

note The keys are unique, duplicates will be replaced by the last one

let args = Args::new()
    .with("key1", &false)
    .with("key2", &"message")
    .with("key3", &41)
    .with("key3", &42);

Implementations§

Source§

impl<'k> Args<'k>

Source

pub fn new() -> Self

Create a new Args builder

Source

pub fn len(&self) -> usize

Length of the args

Source

pub fn is_empty(&self) -> bool

Whether the args is empty

Source

pub fn with(self, key: impl Into<Cow<'k, str>>, val: impl Display) -> Self

Maps a key to a type that implements std::fmt::Display

Source

pub fn iter(&self) -> impl Iterator<Item = (&Cow<'k, str>, &String)> + '_

Trait Implementations§

Source§

impl<'k> Clone for Args<'k>

Source§

fn clone(&self) -> Args<'k>

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<'k> Default for Args<'k>

Source§

fn default() -> Args<'k>

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

impl<'k, K, V> FromIterator<(K, V)> for Args<'k>
where K: Into<Cow<'k, str>>, V: Display,

Source§

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

Creates a value from an iterator. Read more
Source§

impl<'k> IntoIterator for Args<'k>

Source§

type Item = (Cow<'k, str>, String)

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<Cow<'k, str>, String>

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

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<'k> Freeze for Args<'k>

§

impl<'k> RefUnwindSafe for Args<'k>

§

impl<'k> Send for Args<'k>

§

impl<'k> Sync for Args<'k>

§

impl<'k> Unpin for Args<'k>

§

impl<'k> UnwindSafe for Args<'k>

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.