pub struct FeatureChain { /* private fields */ }Expand description
One chain of the feature order: feature names in the order they are to be registered, and the text that says where the chain comes from.
The chain a < b < c states that the feature a comes before b and b
before c. The module documentation gives how the registry build
combines chains and places the features. Read a chain from its text with
FeatureChain::parse.
Display writes the names separated by <.
§Examples
use flm_core::core::registry::FeatureChain;
let chain = FeatureChain::parse("math-mathjax < phfqit", "package phfpack")?;
assert_eq!(chain.names(), ["math-mathjax", "phfqit"]);
assert_eq!(chain.origin(), "package phfpack");
assert_eq!(chain.to_string(), "math-mathjax < phfqit");Implementations§
Source§impl FeatureChain
impl FeatureChain
Sourcepub fn parse(
text: &str,
origin: impl Into<String>,
) -> Result<FeatureChain, ChainError>
pub fn parse( text: &str, origin: impl Into<String>, ) -> Result<FeatureChain, ChainError>
Reads a chain from text, a list of feature names separated by <,
such as math-mathjax < phfqit; origin says where the chain comes
from, for messages.
A name is one or more characters, none of them whitespace or <.
Whitespace around each < and at either end of the text is allowed.
The function checks two things only: that the text has the form
NAME < NAME < … < NAME, with two or more names, and that no name
appears twice. It does not check that the names are features of any
registry.
The origin is a text the caller chooses, such as package phfpack or
front matter of doc.flm, line 4; the registry build quotes it when
the chain is part of a cycle (BuildError::FeatureOrderCycle).
§Errors
ChainError::NotAChain when the text does not have the form, and
ChainError::RepeatedName when a name appears twice.
Sourcepub fn names(&self) -> &[FeatureName]
pub fn names(&self) -> &[FeatureName]
The feature names, in the order the chain places them.
Sourcepub fn origin(&self) -> &str
pub fn origin(&self) -> &str
The text that says where the chain comes from, as given to
FeatureChain::parse or FeatureChain::with_origin.
Sourcepub fn with_origin(self, origin: impl Into<String>) -> FeatureChain
pub fn with_origin(self, origin: impl Into<String>) -> FeatureChain
Returns the chain with the origin origin in place of its own: for a
caller that reads a chain before it knows where the chain is written
(the line of a file, the name of a package).
§Examples
use flm_core::core::registry::FeatureChain;
let chain = FeatureChain::parse("math-mathjax < phfqit", "feature_order[1]")?;
let chain = chain.with_origin("package phfpack");
assert_eq!(chain.origin(), "package phfpack");
assert_eq!(chain.to_string(), "math-mathjax < phfqit");Trait Implementations§
Source§impl Clone for FeatureChain
impl Clone for FeatureChain
Source§impl Debug for FeatureChain
impl Debug for FeatureChain
Source§impl Display for FeatureChain
impl Display for FeatureChain
impl Eq for FeatureChain
Source§impl PartialEq for FeatureChain
impl PartialEq for FeatureChain
impl StructuralPartialEq for FeatureChain
Auto Trait Implementations§
impl Forget for FeatureChain
impl Freeze for FeatureChain
impl Move for FeatureChain
impl RefUnwindSafe for FeatureChain
impl Send for FeatureChain
impl Sync for FeatureChain
impl Unpin for FeatureChain
impl UnsafeUnpin for FeatureChain
impl UnwindSafe for FeatureChain
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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> ⓘ
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> ⓘ
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