pub struct RefinedBrand<A, B, E = String> { /* private fields */ }Expand description
A branded constructor that validates the inner value at runtime.
Mirrors Effect.ts Brand.refined(refine, onFailure).
Implementations§
Source§impl<A: Clone, B, E: Clone> RefinedBrand<A, B, E>
impl<A: Clone, B, E: Clone> RefinedBrand<A, B, E>
Sourcepub fn new(refine: impl Fn(&A) -> Result<(), E> + Send + Sync + 'static) -> Self
pub fn new(refine: impl Fn(&A) -> Result<(), E> + Send + Sync + 'static) -> Self
Create a new refined brand constructor with a validation function.
refine returns Ok(()) when the value is valid, Err(e) otherwise.
Sourcepub fn try_make(&self, value: A) -> Result<Brand<A, B>, E>
pub fn try_make(&self, value: A) -> Result<Brand<A, B>, E>
Try to brand value. Returns Ok(Brand<A,B>) or Err(E).
Sourcepub fn make_option(&self, value: A) -> Option<Brand<A, B>>
pub fn make_option(&self, value: A) -> Option<Brand<A, B>>
Returns Some(Brand<A,B>) if valid, None otherwise.
Auto Trait Implementations§
impl<A, B, E = String> !RefUnwindSafe for RefinedBrand<A, B, E>
impl<A, B, E = String> !UnwindSafe for RefinedBrand<A, B, E>
impl<A, B, E> Freeze for RefinedBrand<A, B, E>
impl<A, B, E> Send for RefinedBrand<A, B, E>where
B: Send,
impl<A, B, E> Sync for RefinedBrand<A, B, E>where
B: Sync,
impl<A, B, E> Unpin for RefinedBrand<A, B, E>where
B: Unpin,
impl<A, B, E> UnsafeUnpin for RefinedBrand<A, B, E>
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
impl<T> Capability for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more