Lowercase

Struct Lowercase 

Source
pub struct Lowercase<Mode> { /* private fields */ }
Expand description

Rule and transformer for ensuring that a string is entirely lowercase.

§Example

use wary::Wary;

#[derive(Wary)]
struct Person {
  #[validate(lowercase)]
  name: String,
  #[validate(lowercase(ascii))]
  greeting: String,
  #[transform(lowercase)]
  message: String,
}

let mut person = Person {
  name: "hello".into(),
  greeting: "hello".into(),
  message: "HELLO".into(),
};

assert!(person.wary(&()).is_ok());
assert_eq!(person.message, "hello");

Implementations§

Source§

impl Lowercase<Unset>

Source

pub const fn new() -> Self

Source

pub const fn ascii(self) -> Lowercase<Ascii>

§Rule

Ensures that the input is entirely lowercase in ascii.

§Transformer

Uses str::make_ascii_lowercase to convert in-place instead of requiring a new allocation with str::to_lowercase.

Trait Implementations§

Source§

impl<I> Rule<I> for Lowercase<Ascii>
where I: AsRef<str> + ?Sized,

Source§

type Context = ()

Additional context required to validate the input.
Source§

fn validate(&self, _ctx: &Self::Context, item: &I) -> Result<()>

Validates the item. Read more
Source§

impl<I> Rule<I> for Lowercase<Unset>
where I: AsRef<str> + ?Sized,

Source§

type Context = ()

Additional context required to validate the input.
Source§

fn validate(&self, _ctx: &Self::Context, item: &I) -> Result<()>

Validates the item. Read more
Source§

impl<I> Transformer<I> for Lowercase<Ascii>
where I: AsMut<str>,

Source§

type Context = ()

Additional context required to transform the input.
Source§

fn transform(&self, _ctx: &Self::Context, item: &mut I)

Transform the input.
Source§

impl Transformer<String> for Lowercase<Unset>

Available on crate feature alloc only.
Source§

type Context = ()

Additional context required to transform the input.
Source§

fn transform(&self, _ctx: &Self::Context, item: &mut String)

Transform the input.

Auto Trait Implementations§

§

impl<Mode> Freeze for Lowercase<Mode>

§

impl<Mode> RefUnwindSafe for Lowercase<Mode>
where Mode: RefUnwindSafe,

§

impl<Mode> Send for Lowercase<Mode>
where Mode: Send,

§

impl<Mode> Sync for Lowercase<Mode>
where Mode: Sync,

§

impl<Mode> Unpin for Lowercase<Mode>
where Mode: Unpin,

§

impl<Mode> UnwindSafe for Lowercase<Mode>
where Mode: UnwindSafe,

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> Compare<Unset> for T
where T: ?Sized,

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, 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> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T