pub struct Sequence { /* private fields */ }Expand description
Sequence.
Sequences are ordered collections of expressions that can be used to match identifiers. Sequences can contain gaps, which allow to implement flexible matching of identifiers with varying numbers of elements, including but not limited to prefix and suffix matching.
Each Element of a Sequence can either be an Expression or a
Gap. An Expression is a logical combination of one or multiple
Id and Selector instances, while a Gap represents a
wildcard that can match any number of elements, including zero.
The following convenience constructors are provided:
Sequence::prefix: Creates a sequence for prefix matching.Sequence::suffix: Creates a sequence for suffix matching.
§Examples
use zrx_id::{selector, Sequence};
// Create sequence
let sequence = Sequence::from([
selector!(location = "zensical.toml")?,
selector!(location = "**/*.md")?,
]);Implementations§
Source§impl Sequence
impl Sequence
Sourcepub fn prefix<T>(sequence: T) -> Selfwhere
T: Into<Self>,
pub fn prefix<T>(sequence: T) -> Selfwhere
T: Into<Self>,
Creates a sequence where the given elements are a prefix.
§Examples
use zrx_id::{selector, Sequence};
// Create sequence for a prefix
let sequence = Sequence::prefix([
selector!(location = "zensical.toml")?,
]);Sourcepub fn suffix<T>(sequence: T) -> Selfwhere
T: Into<Self>,
pub fn suffix<T>(sequence: T) -> Selfwhere
T: Into<Self>,
Creates a sequence where the given elements are a suffix.
§Examples
use zrx_id::{selector, Sequence};
// Create sequence for a suffix
let sequence = Sequence::suffix([
selector!(location = "**/*.md")?,
]);Sourcepub fn iter(&self) -> Iter<'_, Element>
pub fn iter(&self) -> Iter<'_, Element>
Creates an iterator over the sequence.
§Examples
use zrx_id::{selector, Sequence};
// Create sequence
let sequence = Sequence::from([
selector!(location = "zensical.toml")?,
selector!(location = "**/*.md")?,
]);
// Create iterator over sequence
for element in sequence.iter() {
println!("{element:?}");
}Trait Implementations§
impl Eq for Sequence
Source§impl<E> FromIterator<E> for Sequence
impl<E> FromIterator<E> for Sequence
Source§fn from_iter<T>(iter: T) -> Selfwhere
T: IntoIterator<Item = E>,
fn from_iter<T>(iter: T) -> Selfwhere
T: IntoIterator<Item = E>,
Creates a sequence from an iterator.
§Examples
use zrx_id::{selector, Sequence};
// Create sequence from iterator
let sequence = Sequence::from_iter([
selector!(location = "zensical.toml")?,
selector!(location = "**/*.md")?,
]);Source§impl<'a> IntoIterator for &'a Sequence
impl<'a> IntoIterator for &'a Sequence
Source§fn into_iter(self) -> Self::IntoIter
fn into_iter(self) -> Self::IntoIter
Creates an iterator over the sequence.
§Examples
use zrx_id::{selector, Sequence};
// Create sequence
let sequence = Sequence::from([
selector!(location = "zensical.toml")?,
selector!(location = "**/*.md")?,
]);
// Create iterator over sequence
for element in &sequence {
println!("{element:?}");
}Source§impl IntoIterator for Sequence
impl IntoIterator for Sequence
Source§fn into_iter(self) -> Self::IntoIter
fn into_iter(self) -> Self::IntoIter
Creates a consuming iterator over the sequence.
§Examples
use zrx_id::{selector, Sequence};
// Create sequence
let sequence = Sequence::from([
selector!(location = "zensical.toml")?,
selector!(location = "**/*.md")?,
]);
// Create iterator over sequence
for element in sequence {
println!("{element:?}");
}impl StructuralPartialEq for Sequence
Source§impl ToSpecificity for Sequence
impl ToSpecificity for Sequence
Source§fn to_specificity(&self) -> Specificity
fn to_specificity(&self) -> Specificity
Computes the specificity of the sequence.
§Examples
use zrx_id::selector;
use zrx_id::sequence::Sequence;
use zrx_id::specificity::ToSpecificity;
// Create sequence and compute specificity
let sequence = Sequence::from(selector!(location = "**/*.md")?);
assert_eq!(sequence.to_specificity(), (0, 1, 1, 3).into());impl Value for Sequence
Auto Trait Implementations§
impl Freeze for Sequence
impl RefUnwindSafe for Sequence
impl Send for Sequence
impl Sync for Sequence
impl Unpin for Sequence
impl UnsafeUnpin for Sequence
impl UnwindSafe for Sequence
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> IntoResult<T> for Twhere
T: Value,
impl<T> IntoResult<T> for Twhere
T: Value,
Source§fn into_result(self) -> Result<T, Error>
fn into_result(self) -> Result<T, Error>
Converts any value into a step result.
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)?;