Struct snapbox::Substitutions
source · pub struct Substitutions { /* private fields */ }Expand description
Match pattern expressions, see Assert
Built-in expressions:
...on a line of its own: match multiple complete lines[..]: match multiple characters within a line
Implementations§
source§impl Substitutions
impl Substitutions
pub fn new() -> Self
sourcepub fn insert(
&mut self,
key: &'static str,
value: impl Into<Cow<'static, str>>
) -> Result<(), Error>
pub fn insert( &mut self, key: &'static str, value: impl Into<Cow<'static, str>> ) -> Result<(), Error>
Insert an additional match pattern
key must be enclosed in [ and ].
let mut subst = snapbox::Substitutions::new();
subst.insert("[EXE]", std::env::consts::EXE_SUFFIX);sourcepub fn extend(
&mut self,
vars: impl IntoIterator<Item = (&'static str, impl Into<Cow<'static, str>>)>
) -> Result<(), Error>
pub fn extend( &mut self, vars: impl IntoIterator<Item = (&'static str, impl Into<Cow<'static, str>>)> ) -> Result<(), Error>
Insert additional match patterns
keys must be enclosed in [ and ].
sourcepub fn normalize(&self, input: &str, pattern: &str) -> String
pub fn normalize(&self, input: &str, pattern: &str) -> String
Apply match pattern to input
If pattern matches input, then pattern is returned.
Otherwise, input, with as many patterns replaced as possible, will be returned.
let subst = snapbox::Substitutions::new();
let output = subst.normalize("Hello World!", "Hello [..]!");
assert_eq!(output, "Hello [..]!");Trait Implementations§
source§impl Clone for Substitutions
impl Clone for Substitutions
source§fn clone(&self) -> Substitutions
fn clone(&self) -> Substitutions
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for Substitutions
impl Debug for Substitutions
source§impl Default for Substitutions
impl Default for Substitutions
source§fn default() -> Substitutions
fn default() -> Substitutions
Returns the “default value” for a type. Read more
source§impl PartialEq for Substitutions
impl PartialEq for Substitutions
source§fn eq(&self, other: &Substitutions) -> bool
fn eq(&self, other: &Substitutions) -> bool
This method tests for
self and other values to be equal, and is used
by ==.impl Eq for Substitutions
impl StructuralEq for Substitutions
impl StructuralPartialEq for Substitutions
Auto Trait Implementations§
impl RefUnwindSafe for Substitutions
impl Send for Substitutions
impl Sync for Substitutions
impl Unpin for Substitutions
impl UnwindSafe for Substitutions
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