pub struct Specified<T> { /* private fields */ }Expand description
Specified value.
This data type is a thin wrapper around a value of type T, augmenting the
value with its computed Specificity, so it can be efficiently ordered.
Note that specifities are ordered from lowest to highest, with the least
specific value being the first in order. It would be natural to reverse
this order, but this would lead to more complex implementations for when
a specified value is wrapped in an Option.
Implementations§
Source§impl<T> Specified<T>
impl<T> Specified<T>
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Returns the inner value, consuming the specified value.
§Examples
use zrx_id::selector;
use zrx_id::specificity::Specified;
// Create selector
let selector = selector!(location = "**/*.md")?;
// Create specified value from selector
let value = Specified::from(selector.clone());
assert_eq!(value.into_inner(), selector);Source§impl<T> Specified<T>
impl<T> Specified<T>
Sourcepub fn specificity(&self) -> Specificity
pub fn specificity(&self) -> Specificity
Returns the specificity.
Trait Implementations§
Source§impl<T> From<T> for Specified<T>where
T: ToSpecificity,
impl<T> From<T> for Specified<T>where
T: ToSpecificity,
Source§fn from(inner: T) -> Self
fn from(inner: T) -> Self
Creates a specified value from a value.
§Examples
use zrx_id::selector;
use zrx_id::specificity::Specified;
// Create selector
let selector = selector!(location = "**/*.md")?;
// Create specified value from selector
let value = Specified::from(selector);
assert_eq!(value.specificity(), (0, 1, 1, 3).into());Source§impl<T> Ord for Specified<T>where
T: Eq,
impl<T> Ord for Specified<T>where
T: Eq,
Source§fn cmp(&self, other: &Self) -> Ordering
fn cmp(&self, other: &Self) -> Ordering
Orders two values by specificity.
§Examples
use zrx_id::selector;
use zrx_id::specificity::Specified;
// Create and compare selectors by specificity
let a = Specified::from(selector!(location = "**/*.md")?);
let b = Specified::from(selector!(location = "*.md")?);
assert!(a < b);1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<T> PartialEq for Specified<T>where
T: PartialEq,
impl<T> PartialEq for Specified<T>where
T: PartialEq,
Source§fn eq(&self, other: &Self) -> bool
fn eq(&self, other: &Self) -> bool
Compares two specified values for equality.
§Examples
use zrx_id::selector;
use zrx_id::specificity::Specified;
// Create and compare selectors
let a = Specified::from(selector!(location = "*.md")?);
let b = Specified::from(selector!(location = "*.md")?);
assert_eq!(a, b);Source§impl<T> PartialOrd for Specified<T>where
T: Eq,
impl<T> PartialOrd for Specified<T>where
T: Eq,
Source§fn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
Orders two values by specificity.
§Examples
use zrx_id::selector;
use zrx_id::specificity::Specified;
// Create and compare selectors by specificity
let a = Specified::from(selector!(location = "**/*.md")?);
let b = Specified::from(selector!(location = "*.md")?);
assert!(a < b);impl<T> Eq for Specified<T>where
T: Eq,
Auto Trait Implementations§
impl<T> Freeze for Specified<T>where
T: Freeze,
impl<T> RefUnwindSafe for Specified<T>where
T: RefUnwindSafe,
impl<T> Send for Specified<T>where
T: Send,
impl<T> Sync for Specified<T>where
T: Sync,
impl<T> Unpin for Specified<T>where
T: Unpin,
impl<T> UnsafeUnpin for Specified<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Specified<T>where
T: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<K, V> TryAsStorage<K> for V
impl<K, V> TryAsStorage<K> for V
Source§fn try_as_storage(
item: &(dyn Any + 'static),
) -> Result<<V as TryAsStorage<K>>::Target<'_>, Error>
fn try_as_storage( item: &(dyn Any + 'static), ) -> Result<<V as TryAsStorage<K>>::Target<'_>, Error>
Attempts to convert into a storage reference.
§Errors
The following errors might be returned:
Error::Downcast: Item cannot be downcast.
§Examples
use std::any::Any;
use zrx_storage::convert::TryAsStorage;
use zrx_storage::Storage;
// Create storage and initial state
let mut storage = Storage::default();
storage.insert("key", 42);
// Obtain type-erased reference
let item: &dyn Any = &storage;
// Obtain storage reference
let storage = <i32>::try_as_storage(item)?;Source§impl<K, V> TryAsStorageMut<K> for V
impl<K, V> TryAsStorageMut<K> for V
Source§fn try_as_storage_mut(
item: &mut (dyn Any + 'static),
) -> Result<<V as TryAsStorageMut<K>>::Target<'_>, Error>
fn try_as_storage_mut( item: &mut (dyn Any + 'static), ) -> Result<<V as TryAsStorageMut<K>>::Target<'_>, Error>
Attempts to convert into a mutable storage reference.
§Errors
The following errors might be returned:
Error::Downcast: Item cannot be downcast.
§Examples
use std::any::Any;
use zrx_storage::convert::TryAsStorageMut;
use zrx_storage::Storage;
// Create storage and initial state
let mut storage = Storage::default();
storage.insert("key", 42);
// Obtain mutable type-erased reference
let item: &mut dyn Any = &mut storage;
// Obtain mutable storage reference
let storage = <i32>::try_as_storage_mut(item)?;