Skip to content

Commit

Permalink
Rename match_at_index in util.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
gngeorgiev committed Nov 22, 2021
1 parent 0294e2d commit 1cf78e2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ pub(crate) fn is_any_version(v: &str) -> bool {
v.is_empty() || v == "*" || unicase::eq(v, "x")
}

pub(crate) fn match_at_index_str<'a>(v: &'a Captures, i: usize) -> &'a str {
pub(crate) fn match_at_index<'a>(v: &'a Captures, i: usize) -> &'a str {
v.get(i).map_or("", |v| v.as_str())
}

pub(crate) fn match_at_index(v: &Captures, i: usize) -> String {
pub(crate) fn match_at_index_owned(v: &Captures, i: usize) -> String {
v.get(i).map_or(String::new(), |v| v.as_str().to_owned())
}

Expand All @@ -33,7 +33,7 @@ pub(crate) fn replacer<'a>(
move |cap: &regex::Captures| {
let mut args: Vec<String> = vec![];
for i in 0..6 {
args.push(match_at_index(cap, i))
args.push(match_at_index_owned(cap, i))
}

func(args)
Expand Down

0 comments on commit 1cf78e2

Please sign in to comment.