pub struct FieldName(pub Cow<'static, str>);
Expand description
Represents the field level context for validation functions. Its value is the name of the field to be validated.
Tuple Fields§
§0: Cow<'static, str>
Implementations§
Methods from Deref<Target = Cow<'static, str>>§
Sourcepub fn is_borrowed(&self) -> bool
🔬This is a nightly-only experimental API. (cow_is_borrowed
)
pub fn is_borrowed(&self) -> bool
cow_is_borrowed
)Returns true if the data is borrowed, i.e. if to_mut
would require additional work.
§Examples
#![feature(cow_is_borrowed)]
use std::borrow::Cow;
let cow = Cow::Borrowed("moo");
assert!(cow.is_borrowed());
let bull: Cow<'_, str> = Cow::Owned("...moo?".to_string());
assert!(!bull.is_borrowed());
Sourcepub fn is_owned(&self) -> bool
🔬This is a nightly-only experimental API. (cow_is_borrowed
)
pub fn is_owned(&self) -> bool
cow_is_borrowed
)Returns true if the data is owned, i.e. if to_mut
would be a no-op.
§Examples
#![feature(cow_is_borrowed)]
use std::borrow::Cow;
let cow: Cow<'_, str> = Cow::Owned("moo".to_string());
assert!(cow.is_owned());
let bull = Cow::Borrowed("...moo?");
assert!(!bull.is_owned());
Trait Implementations§
Source§impl<T> Validate<AssertFalse, FieldName> for Twhere
T: HasCheckedValue,
impl<T> Validate<AssertFalse, FieldName> for Twhere
T: HasCheckedValue,
Source§fn validate(
self,
name: impl Into<FieldName>,
_constraint: &AssertFalse,
) -> Validation<AssertFalse, Self>
fn validate( self, name: impl Into<FieldName>, _constraint: &AssertFalse, ) -> Validation<AssertFalse, Self>
Validates this value for being compliant to the specified constraint
C
in the given context S
.Source§impl<T> Validate<AssertTrue, FieldName> for Twhere
T: HasCheckedValue,
impl<T> Validate<AssertTrue, FieldName> for Twhere
T: HasCheckedValue,
Source§fn validate(
self,
name: impl Into<FieldName>,
_constraint: &AssertTrue,
) -> Validation<AssertTrue, Self>
fn validate( self, name: impl Into<FieldName>, _constraint: &AssertTrue, ) -> Validation<AssertTrue, Self>
Validates this value for being compliant to the specified constraint
C
in the given context S
.impl Eq for FieldName
impl StructuralPartialEq for FieldName
Auto Trait Implementations§
impl Freeze for FieldName
impl RefUnwindSafe for FieldName
impl Send for FieldName
impl Sync for FieldName
impl Unpin for FieldName
impl UnwindSafe for FieldName
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more