Struct refined_type::Refined
source · pub struct Refined<RULE>where
RULE: Rule,{ /* private fields */ }Expand description
Refined is a versatile type in ensuring that T satisfies the conditions of RULE (predicate type)
§Example
use refined_type::rule::{NonEmptyString, NonEmptyStringRule};
use refined_type::Refined;
let non_empty_string_result = Refined::<NonEmptyStringRule>::new("Hello World".to_string());
assert_eq!(non_empty_string_result.unwrap().into_value(), "Hello World");
let empty_string_result = Refined::<NonEmptyStringRule>::new("".to_string());
assert!(empty_string_result.is_err())Implementations§
source§impl<K, V, S> Refined<Not<EmptyRule<HashMap<K, V, S>>>>
impl<K, V, S> Refined<Not<EmptyRule<HashMap<K, V, S>>>>
pub fn into_iter(self) -> NonEmpty<IntoIter<K, V>>
pub fn iter(&self) -> NonEmpty<Iter<'_, K, V>>
pub fn hasher(&self) -> &S
pub fn capacity(&self) -> usize
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn keys(&self) -> Keys<'_, K, V>
pub fn into_keys(self) -> IntoKeys<K, V>
pub fn values(&self) -> Values<'_, K, V>
pub fn into_values(self) -> IntoValues<K, V>
source§impl Refined<Not<EmptyRule<String>>>
impl Refined<Not<EmptyRule<String>>>
pub fn insert(self, idx: usize, ch: char) -> Self
pub fn push(self, ch: char) -> Self
pub fn push_str(self, string: &str) -> Self
pub fn as_bytes(&self) -> NonEmptyVec<u8>
pub fn repeat(&self, n: usize) -> Self
pub fn to_ascii_lowercase(&self) -> Self
pub fn to_lowercase(&self) -> Self
pub fn to_ascii_uppercase(&self) -> Self
pub fn to_uppercase(&self) -> Self
pub fn capacity(&self) -> usize
pub fn len(&self) -> usize
source§impl<T> Refined<Not<EmptyRule<VecDeque<T>>>>
impl<T> Refined<Not<EmptyRule<VecDeque<T>>>>
pub fn into_iter(self) -> NonEmpty<IntoIter<T>>
pub fn iter(&self) -> NonEmpty<Iter<'_, T>>
pub fn get(&self, index: usize) -> Option<&T>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn push_front(self, value: T) -> Self
pub fn push_back(self, value: T) -> Self
source§impl<I: ExactSizeIterator + EmptyDefinition> Refined<Not<EmptyRule<I>>>
impl<I: ExactSizeIterator + EmptyDefinition> Refined<Not<EmptyRule<I>>>
pub fn map<B, F>(self, f: F) -> Refined<NonEmptyRule<Map<I, F>>>
pub fn collect<B: FromIterator<I::Item> + EmptyDefinition>(self) -> NonEmpty<B>where
Self: Sized,
Trait Implementations§
source§impl<'de, RULE, T> Deserialize<'de> for Refined<RULE>where
RULE: Rule<Item = T>,
T: Deserialize<'de>,
impl<'de, RULE, T> Deserialize<'de> for Refined<RULE>where
RULE: Rule<Item = T>,
T: Deserialize<'de>,
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl<RULE> Ord for Refined<RULE>
impl<RULE> Ord for Refined<RULE>
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl<RULE> PartialEq for Refined<RULE>
impl<RULE> PartialEq for Refined<RULE>
source§impl<RULE> PartialOrd for Refined<RULE>
impl<RULE> PartialOrd for Refined<RULE>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read moreimpl<RULE> Eq for Refined<RULE>
impl<RULE> StructuralPartialEq for Refined<RULE>where
RULE: Rule,
Auto Trait Implementations§
impl<RULE> Freeze for Refined<RULE>
impl<RULE> RefUnwindSafe for Refined<RULE>
impl<RULE> Send for Refined<RULE>
impl<RULE> Sync for Refined<RULE>
impl<RULE> Unpin for Refined<RULE>
impl<RULE> UnwindSafe for Refined<RULE>
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