Skip to main content

AllowedSpecifier

Struct AllowedSpecifier 

Source
pub struct AllowedSpecifier {
    pub types: u16,
    pub alternate_forms: u8,
    pub allowed_fill_characters: Option<String>,
    pub forbidden_fill_characters: Option<String>,
    pub alignments: u8,
    pub signs: u8,
    pub pad_zeros: u8,
    pub allowed_widths: Option<Vec<Width>>,
    pub forbidden_widths: Option<Vec<Width>>,
    pub allowed_precisions: Option<Vec<Precision>>,
    pub forbidden_precisions: Option<Vec<Precision>>,
}
Expand description

Helper structure to specify the constraints of an expected argument.

use dfmt::*;

let allowed_specifier =
    AllowedSpecifier::all()
        .forbid(Type::Display);

assert!(Template::parse("Hello, {world}!").unwrap()
    .expect_argument("world", &allowed_specifier)
    .is_err());

Fields§

§types: u16§alternate_forms: u8§allowed_fill_characters: Option<String>§forbidden_fill_characters: Option<String>§alignments: u8§signs: u8§pad_zeros: u8§allowed_widths: Option<Vec<Width>>§forbidden_widths: Option<Vec<Width>>§allowed_precisions: Option<Vec<Precision>>§forbidden_precisions: Option<Vec<Precision>>

Implementations§

Source§

impl AllowedSpecifier

Source

pub fn all() -> Self

Source

pub fn none() -> Self

Source

pub fn is_within_constraints(&self, specifier: &Specifier) -> bool

Trait Implementations§

Source§

impl AllowedSpecifierBuilder<Alignment> for AllowedSpecifier

Source§

fn allow(self, constraint: Alignment) -> Self

Source§

fn forbid(self, constraint: Alignment) -> Self

Source§

impl AllowedSpecifierBuilder<AlternateForm> for AllowedSpecifier

Source§

fn allow(self, constraint: AlternateForm) -> Self

Source§

fn forbid(self, constraint: AlternateForm) -> Self

Source§

impl AllowedSpecifierBuilder<Option<String>> for AllowedSpecifier

Source§

fn allow(self, constraint: Option<String>) -> Self

Source§

fn forbid(self, constraint: Option<String>) -> Self

Source§

impl AllowedSpecifierBuilder<Option<Vec<Precision>>> for AllowedSpecifier

Source§

fn allow(self, constraint: Option<Vec<Precision>>) -> Self

Source§

fn forbid(self, constraint: Option<Vec<Precision>>) -> Self

Source§

impl AllowedSpecifierBuilder<Option<Vec<Width>>> for AllowedSpecifier

Source§

fn allow(self, constraint: Option<Vec<Width>>) -> Self

Source§

fn forbid(self, constraint: Option<Vec<Width>>) -> Self

Source§

impl AllowedSpecifierBuilder<PadZero> for AllowedSpecifier

Source§

fn allow(self, constraint: PadZero) -> Self

Source§

fn forbid(self, constraint: PadZero) -> Self

Source§

impl AllowedSpecifierBuilder<Precision> for AllowedSpecifier

Source§

fn allow(self, constraint: Precision) -> Self

Source§

fn forbid(self, constraint: Precision) -> Self

Source§

impl AllowedSpecifierBuilder<Sign> for AllowedSpecifier

Source§

fn allow(self, constraint: Sign) -> Self

Source§

fn forbid(self, constraint: Sign) -> Self

Source§

impl AllowedSpecifierBuilder<Type> for AllowedSpecifier

Source§

fn allow(self, constraint: Type) -> Self

Source§

fn forbid(self, constraint: Type) -> Self

Source§

impl AllowedSpecifierBuilder<Width> for AllowedSpecifier

Source§

fn allow(self, constraint: Width) -> Self

Source§

fn forbid(self, constraint: Width) -> Self

Source§

impl Clone for AllowedSpecifier

Source§

fn clone(&self) -> AllowedSpecifier

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 AllowedSpecifier

Source§

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

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

impl PartialEq for AllowedSpecifier

Source§

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

Source§

impl StructuralPartialEq for AllowedSpecifier

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.