Refactor reimplementation of Option<T> Enum.
This Align
Enum could be represented as Option<Aligned>
instead. Ignore the branch name I was working on something else at first.
The reason why that enum existed I guess was that fn parse_align_mode(s: &str) -> Option<Align>
needed to have a 3 states if I understand it correctly,
so the following would be possible:
pub enum Align {
None,
Aligned { align: AlignMode, fit: FitMode },
}
fn parse_align_mode(s: &str) -> Option<Align> {
match s {
"none" => Some(Align::None),
"bar" => Some(Align::Aligned { .. }),
_ => None,
}
}
The same states above are now represented by fn parse_align_mode(s: &str) -> Result<Option<Align>, ()>
.
pub struct Align {
align: AlignMode,
pub fit: FitMode,
}
fn parse_align_mode(s: &str) -> Result<Option<Align>, ()> {
match s {
"none" => Ok(None),
"bar" => Ok(Some(Align { .. }),
_ => Err(_),
}
}
Edited by Jordan Petridis