Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improv: Define Page enum instead of just using strings
Slightly more efficient, allows exhaustive matching, etc.
- Loading branch information
Showing
4 changed files
with
44 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] | ||
pub enum Page { | ||
Layer1, | ||
Layer2, | ||
Keycaps, | ||
Logical, | ||
Electrical, | ||
} | ||
|
||
impl Page { | ||
pub fn name(&self) -> &'static str { | ||
match self { | ||
Self::Layer1 => "Layer 1", | ||
Self::Layer2 => "Layer 2", | ||
Self::Keycaps => "Keycaps", | ||
Self::Logical => "Logical", | ||
Self::Electrical => "Electrical" | ||
} | ||
} | ||
|
||
pub fn iter_all() -> impl Iterator<Item=Self> { | ||
vec![ | ||
Self::Layer1, | ||
Self::Layer2, | ||
Self::Keycaps, | ||
Self::Logical, | ||
Self::Electrical, | ||
].into_iter() | ||
} | ||
} |