From 3a5b7dd83642f5ab93aa70b612dcdbbc10e70935 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Thu, 21 Apr 2016 16:49:18 -0400 Subject: find_alias_in_file: Return list of aliases not alias lines My next step is to get the list produced by this function and use it to build a new alias of `#{alias}-#{id + 1}`. In trying to figure out how best to do that, I realised that it would be easier to do if I had actual aliases to work with instead of full Mutt alias lines that I'd have to parse (again). Update our function to give us a list of aliases instead of full alias lines. --- src/main.rs | 2 +- src/tests.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 06f6eb9..fdeab31 100644 --- a/src/main.rs +++ b/src/main.rs @@ -102,7 +102,7 @@ fn find_alias_in_file(alias: &Alias, file: &str) -> Result, AliasSea } if split[1].starts_with(&alias.alias) { - matches.push(line.to_owned()); + matches.push(split[1].to_owned()); } } diff --git a/src/tests.rs b/src/tests.rs index df61825..0dc3901 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -75,8 +75,8 @@ fn find_alias_in_file_alias_is_new() { fn find_alias_in_file_finds_a_match() { assert_eq!( Ok(vec![ - "alias farnsworth-hubert Hubert Farnsworth ".to_owned(), - "alias farnsworth-hubert-2 Hubert Farnsworth ".to_owned() + "farnsworth-hubert".to_owned(), + "farnsworth-hubert-2".to_owned() ]), find_alias_in_file( &Alias { -- cgit v1.2.3