pub trait Refining: Deref<Target = Self::Value> + Sealed {
type Value: ?Sized;
type Predicate: Predicate<Self::Value> + ?Sized;
type Context: TypeStr + ?Sized;
// Required methods
unsafe fn unchecked_ref(value: &Self::Value) -> &Self;
unsafe fn unchecked(value: Self::Value) -> Self
where Self::Value: Sized;
fn get_ref(&self) -> &Self::Value;
fn get(self) -> Self::Value
where Self::Value: Sized;
fn checked_ref(value: &Self::Value) -> RecoverableRefinementRef<'_, Self>;
fn checked(value: Self::Value) -> RecoverableRefinement<Self>
where Self::Value: Sized,
Self: Sized;
// Provided method
fn is_fine(value: &Self::Value) -> bool { ... }
}Expand description
Refinement methods.
This sealed trait is used for generics over Refinement<T, P, C>.
Required Associated Types§
Sourcetype Value: ?Sized
type Value: ?Sized
The refinement value (T in Refinement<T, P, C>).
Sourcetype Predicate: Predicate<Self::Value> + ?Sized
type Predicate: Predicate<Self::Value> + ?Sized
The refinement predicate (P in Refinement<T, P, C>).
Sourcetype Context: TypeStr + ?Sized
type Context: TypeStr + ?Sized
The refinement context (C in Refinement<T, P, C>).
Required Methods§
Sourceunsafe fn unchecked_ref(value: &Self::Value) -> &Self
unsafe fn unchecked_ref(value: &Self::Value) -> &Self
Constructs Self from Self::Value by reference without checking.
§Safety
This method should only be called for references that satisfy Self::Predicate.
Alternatively, this can be checked using the is_fine method.
Sourceunsafe fn unchecked(value: Self::Value) -> Self
unsafe fn unchecked(value: Self::Value) -> Self
Constructs Self from Self::Value without checking.
§Safety
This method should only be called for values that satisfy Self::Predicate.
Alternatively, this can be checked using the is_fine method.
Sourcefn checked_ref(value: &Self::Value) -> RecoverableRefinementRef<'_, Self>
fn checked_ref(value: &Self::Value) -> RecoverableRefinementRef<'_, Self>
Constructs Self from Self::Value by reference.
§Errors
Returns Error<Self::Value, Self::Predicate, Self::Context>
reference in case the reference does not satisfy the predicate.
Sourcefn checked(value: Self::Value) -> RecoverableRefinement<Self>
fn checked(value: Self::Value) -> RecoverableRefinement<Self>
Constructs Self from Self::Value.
§Errors
Returns Error<Self::Value, Self::Predicate, Self::Context>
in case the value does not satisfy the predicate.
Provided Methods§
Sourcefn is_fine(value: &Self::Value) -> bool
fn is_fine(value: &Self::Value) -> bool
Checks whether the given Self::Value satisfies Self::Predicate.
This is the same as calling Self::Predicate::check on the value.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".