pub enum Fragment<'a> {
Raw(&'a str),
Regex(Regex),
}Expand description
Represent’s a subfeature’s fragment.
This is used to locate a subfeature’s exact location within a surrounding feature.
Variants§
Raw(&'a str)
A raw subfeature fragment.
This is useful primarily for matching an exact fragment within a larger feature, e.g. a string literal.
It shouldn’t be used to match things like expressions, since they
might contain whitespace that won’t exactly match the surrounding
feature. For that, Fragment::Regex is appropriate.
Regex(Regex)
A regular expression for matching a subfeature.
This is useful primarily for matching any kind of subfeature that might contain multiple lines, e.g. a multi-line GitHub Actions expression, since the subfeature’s indentation won’t necessarily match the surrounding feature’s YAML-level indentation.
Implementations§
Source§impl<'a> Fragment<'a>
impl<'a> Fragment<'a>
Sourcepub fn new(fragment: &'a str) -> Self
pub fn new(fragment: &'a str) -> Self
Create a new Fragment from the given string.
The created fragment’s behavior depends on whether the input contains newlines or not: if there are no newlines then the fragment is a “raw” fragment that gets matched verbatim. If there are newlines, then the fragment is a “regex” fragment that allows a degree of whitespace malleability to allow for matching against a YAML feature with its own syntactically relevant whitespace.