pub struct RegexN<Rep>(pub Regex, pub Rep, pub usize);
Expand description
RegexN(re, new, n)
replaces first n
matches re
with new
.
The type of new
must implement Replacer
.
See regex
for details.
let re = Regex::new(r"(?P<y>\d{4})/(?P<m>\d{2})").unwrap();
assert_eq!(
RegexN(re.clone(), "$m-$y", 1).rewrite("2021/10/2022/12"),
"10-2021/2022/12"
);
assert_eq!(
RegexN(re, "$m-$y", 3).rewrite("2021/10/2022/12"),
"10-2021/12-2022"
);
Tuple Fields§
§0: Regex
§1: Rep
§2: usize
Trait Implementations§
Auto Trait Implementations§
impl<Rep> Freeze for RegexN<Rep>where
Rep: Freeze,
impl<Rep> RefUnwindSafe for RegexN<Rep>where
Rep: RefUnwindSafe,
impl<Rep> Send for RegexN<Rep>where
Rep: Send,
impl<Rep> Sync for RegexN<Rep>where
Rep: Sync,
impl<Rep> Unpin for RegexN<Rep>where
Rep: Unpin,
impl<Rep> UnwindSafe for RegexN<Rep>where
Rep: UnwindSafe,
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