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