fix merge issues #1 & #2; minor version bump

This commit is contained in:
2020-07-02 16:52:40 +01:00
parent 4978d263f1
commit 5d40222120
3 changed files with 19 additions and 17 deletions

View File

@@ -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()
);
}