refactor: HintAlignment -> ui/hint_alignment.rs

This commit is contained in:
graelo 2021-03-20 19:58:31 +01:00
parent 6ba1bd9454
commit 7c7799ffbd
3 changed files with 29 additions and 27 deletions

26
src/ui/hint_alignment.rs Normal file
View file

@ -0,0 +1,26 @@
use clap::Clap;
use std::str::FromStr;
use crate::error::ParseError;
/// Describes if, during rendering, a hint should aligned to the leading edge of
/// the matched text, or to its trailing edge.
#[derive(Debug, Clap)]
pub enum HintAlignment {
Leading,
Trailing,
}
impl FromStr for HintAlignment {
type Err = ParseError;
fn from_str(s: &str) -> Result<HintAlignment, ParseError> {
match s {
"leading" => Ok(HintAlignment::Leading),
"trailing" => Ok(HintAlignment::Trailing),
_ => Err(ParseError::ExpectedString(String::from(
"leading or trailing",
))),
}
}
}