libregex: impl Replacer for FnMut(&Captures) -> String implementors
This commit is contained in:
parent
01d2e46a2d
commit
61ba334452
@ -585,7 +585,7 @@ impl<'t> Replacer for &'t str {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'t> Replacer for |&Captures|: 't -> String {
|
||||
impl<F> Replacer for F where F: FnMut(&Captures) -> String {
|
||||
fn reg_replace<'a>(&'a mut self, caps: &Captures) -> CowString<'a> {
|
||||
(*self)(caps).into_cow()
|
||||
}
|
||||
@ -767,7 +767,7 @@ impl<'t> Captures<'t> {
|
||||
// How evil can you get?
|
||||
// FIXME: Don't use regexes for this. It's completely unnecessary.
|
||||
let re = Regex::new(r"(^|[^$]|\b)\$(\w+)").unwrap();
|
||||
let text = re.replace_all(text, |refs: &Captures| -> String {
|
||||
let text = re.replace_all(text, |&mut: refs: &Captures| -> String {
|
||||
let (pre, name) = (refs.at(1), refs.at(2));
|
||||
format!("{}{}", pre,
|
||||
match from_str::<uint>(name.as_slice()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user