Skip to content

Commit 38c4fb8

Browse files
committed
refactor(filters)!: Rename replace regex group with redacted
1 parent 9e4ad59 commit 38c4fb8

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

crates/snapbox/src/filters/redactions.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ impl Redactions {
3535
///
3636
/// With the `regex` feature, you can define patterns using regexes.
3737
/// You can choose to replace a subset of the regex by giving it the named capture group
38-
/// `replace`.
38+
/// `redacted`.
3939
///
4040
/// ```rust
4141
/// # #[cfg(feature = "regex")] {
4242
/// let mut subst = snapbox::Redactions::new();
43-
/// subst.insert("[OBJECT]", regex::Regex::new("(?<replace>(world|moon))").unwrap());
43+
/// subst.insert("[OBJECT]", regex::Regex::new("(?<redacted>(world|moon))").unwrap());
4444
/// # }
4545
/// ```
4646
pub fn insert(
@@ -135,7 +135,7 @@ impl RedactedValueInner {
135135
#[cfg(feature = "regex")]
136136
Self::Regex(r) => {
137137
let captures = r.captures(buffer)?;
138-
let m = captures.name("replace").or_else(|| captures.get(0))?;
138+
let m = captures.name("redacted").or_else(|| captures.get(0))?;
139139
Some(m.range())
140140
}
141141
}
@@ -561,8 +561,11 @@ mod test {
561561
let input = "Hello world!";
562562
let pattern = "Hello [OBJECT]!";
563563
let mut sub = Redactions::new();
564-
sub.insert("[OBJECT]", regex::Regex::new("(?<replace>world)!").unwrap())
565-
.unwrap();
564+
sub.insert(
565+
"[OBJECT]",
566+
regex::Regex::new("(?<redacted>world)!").unwrap(),
567+
)
568+
.unwrap();
566569
let actual = normalize(input, pattern, &sub);
567570
assert_eq!(actual, pattern);
568571
}

0 commit comments

Comments
 (0)