@@ -145,7 +145,7 @@ fn segments_from_string(string: String) -> Vec<String> {
|
||||
/// tries to use an existing ID - if it is already in use, generate a new one
|
||||
/// then return the ID (either original or new)
|
||||
/// todo refactor (unnecessary clones etc.)
|
||||
fn try_id(ids: Vec<String>, id: String) -> String {
|
||||
fn try_id(ids: &Vec<String>, id: &String) -> String {
|
||||
let id = id.clone();
|
||||
let ids = ids.clone();
|
||||
if is_id_available(&ids, &id) {
|
||||
@@ -242,12 +242,12 @@ mod test {
|
||||
fn test_try_id() {
|
||||
// does a conflict generate a new ID?
|
||||
assert_eq!(
|
||||
try_id(vec!["0".to_string(), "1".to_string()], "1".to_string()),
|
||||
try_id(&vec!["0".to_string(), "1".to_string()], &"1".to_string()),
|
||||
"2".to_string()
|
||||
);
|
||||
// with no conflict, does the ID remain the same?
|
||||
assert_eq!(
|
||||
try_id(vec!["0".to_string(), "1".to_string()], "3".to_string()),
|
||||
try_id(&vec!["0".to_string(), "1".to_string()], &"3".to_string()),
|
||||
"3".to_string()
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user