diff options
| author | Teddy Wing | 2016-04-21 02:47:29 -0400 | 
|---|---|---|
| committer | Teddy Wing | 2016-04-21 02:47:29 -0400 | 
| commit | 9b56cecda8fb33cb006d40d2e367bca2796c7d23 (patch) | |
| tree | 18a3a0c195e6b8c42279a2b3cb171ad1f4e8d11e /src/tests.rs | |
| parent | 34233725b026212f8e8dd880e00b17cf22324d84 (diff) | |
| download | mutt-alias-auto-add-9b56cecda8fb33cb006d40d2e367bca2796c7d23.tar.bz2 | |
find_alias_in_file: Return a vector of matches
Instead of returning a boolean value, get all lines that include the
alias being searched for. This will give us a list of values like:
    Ok([
        "alias farnsworth-hubert Hubert Farnsworth <professor@planetexpress.com>",
        "alias farnsworth-hubert-2 Hubert Farnsworth <other@planetexpress.com>",
        "alias farnsworth-hubert-3 Hubert Farnsworth <other2@planetexpress.com>"
    ])
Our list will contain all Mutt alias calls that start with the given
alias string.
Use my new learnings from the Error Handling section of the Rust book
(http://doc.rust-lang.org/book/error-handling.html). We return a Result
type so that we can communicate both File IO errors and our own custom
matching errors. We define a new error type that allows us to provide
information about the reason for our own errors.
Note that I haven't yet implemented the required `fmt::Display` and
`error::Error` methods on my custom error type yet as those didn't
appear to be crucial to just getting this working.
Change the `line.unwrap()` line to `try!(line)` so that we don't panic
in the event of an error, but instead bubble the error upstream.
If we come across a Mutt alias that has the same email as the inputted
search alias, we want to abort because we shouldn't add a new Mutt alias
line for an existing email address that's already been aliased.
Diffstat (limited to 'src/tests.rs')
0 files changed, 0 insertions, 0 deletions
