Struct snapbox::filter::Redactions
source · pub struct Redactions { /* private fields */ }
Expand description
Match pattern expressions, see Assert
Built-in placeholders:
...
on a line of its own: match multiple complete lines[..]
: match multiple characters within a line
Implementations§
source§impl Redactions
impl Redactions
pub fn new() -> Self
sourcepub fn insert(
&mut self,
placeholder: &'static str,
value: impl Into<RedactedValue>
) -> Result<()>
pub fn insert( &mut self, placeholder: &'static str, value: impl Into<RedactedValue> ) -> Result<()>
Insert an additional match pattern
placeholder
must be enclosed in [
and ]
.
let mut subst = snapbox::Redactions::new();
subst.insert("[EXE]", std::env::consts::EXE_SUFFIX);
sourcepub fn extend(
&mut self,
vars: impl IntoIterator<Item = (&'static str, impl Into<RedactedValue>)>
) -> Result<()>
pub fn extend( &mut self, vars: impl IntoIterator<Item = (&'static str, impl Into<RedactedValue>)> ) -> Result<()>
Insert additional match patterns
placeholders must be enclosed in [
and ]
.
pub fn remove(&mut self, placeholder: &'static str) -> Result<()>
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::Redactions::new();
let output = subst.normalize("Hello World!", "Hello [..]!");
assert_eq!(output, "Hello [..]!");
Trait Implementations§
source§impl Clone for Redactions
impl Clone for Redactions
source§fn clone(&self) -> Redactions
fn clone(&self) -> Redactions
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 Redactions
impl Debug for Redactions
source§impl Default for Redactions
impl Default for Redactions
source§fn default() -> Redactions
fn default() -> Redactions
Returns the “default value” for a type. Read more
source§impl PartialEq for Redactions
impl PartialEq for Redactions
source§fn eq(&self, other: &Redactions) -> bool
fn eq(&self, other: &Redactions) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Eq for Redactions
impl StructuralPartialEq for Redactions
Auto Trait Implementations§
impl Freeze for Redactions
impl RefUnwindSafe for Redactions
impl Send for Redactions
impl Sync for Redactions
impl Unpin for Redactions
impl UnwindSafe for Redactions
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