refactor: use custom Result

This commit is contained in:
graelo 2021-10-24 11:57:25 +02:00
parent 077d16311e
commit 7d1bb69c6f
8 changed files with 34 additions and 33 deletions

View file

@ -1,4 +1,4 @@
use crate::error;
use crate::{error::ParseError, Result};
/// Catalog of available alphabets.
///
@ -41,7 +41,7 @@ const ALPHABETS: [(&str, &str); 21] = [
/// Letters 'n' and 'N' are systematically removed to prevent conflict with
/// navigation keys (arrows and 'n' 'N'). Letters 'y' and 'Y' are also removed
/// to prevent conflict with yank/copy.
pub fn parse_alphabet(src: &str) -> Result<Alphabet, error::ParseError> {
pub fn parse_alphabet(src: &str) -> Result<Alphabet> {
let alphabet_pair = ALPHABETS.iter().find(|&(name, _letters)| name == &src);
match alphabet_pair {
@ -49,7 +49,7 @@ pub fn parse_alphabet(src: &str) -> Result<Alphabet, error::ParseError> {
let letters = letters.replace(&['n', 'N', 'y', 'Y'][..], "");
Ok(Alphabet(letters))
}
None => Err(error::ParseError::UnknownAlphabet),
None => Err(ParseError::UnknownAlphabet),
}
}