Skip to content

Commit

Permalink
Remove unused FromStr impls
Browse files Browse the repository at this point in the history
  • Loading branch information
lunacookies committed Oct 16, 2023
1 parent e611603 commit 615ab3a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 52 deletions.
30 changes: 0 additions & 30 deletions crates/model/src/pipe/color.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::ops::Range;
use std::str::FromStr;

#[derive(Clone, Copy)]
pub struct Color {
Expand Down Expand Up @@ -90,19 +89,6 @@ pub enum ColorMode {
None,
}

impl FromStr for ColorMode {
type Err = anyhow::Error;

fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(match s {
"ansi" => Self::Ansi,
"rgb" => Self::Rgb,
"none" => Self::None,
_ => anyhow::bail!(r#"unknown color mode (expected “ansi”, “rgb”, or “none”)"#),
})
}
}

#[derive(Clone, Copy, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum Palette {
Expand All @@ -112,22 +98,6 @@ pub enum Palette {
Matrix,
}

impl FromStr for Palette {
type Err = anyhow::Error;

fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(match s {
"default" => Self::Default,
"darker" => Self::Darker,
"pastel" => Self::Pastel,
"matrix" => Self::Matrix,
_ => anyhow::bail!(
r#"unknown palette (expected “default”, “darker”, “pastel”, or “matrix”)"#
),
})
}
}

impl Palette {
pub(super) fn get_hue_range(self) -> Range<f32> {
match self {
Expand Down
36 changes: 14 additions & 22 deletions crates/model/src/pipe/kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,27 +86,6 @@ enum KindWidth {
Custom(NonZeroUsize),
}

impl FromStr for Kind {
type Err = anyhow::Error;

fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(match s {
"heavy" => Self::Heavy,
"light" => Self::Light,
"curved" => Self::Curved,
"knobby" => Self::Knobby,
"emoji" => Self::Emoji,
"outline" => Self::Outline,
"dots" => Self::Dots,
"blocks" => Self::Blocks,
"sus" => Self::Sus,
_ => anyhow::bail!(
r#"unknown pipe kind (expected “heavy”, “light”, “curved”, “knobby”, “emoji”, “outline”, “dots”, “blocks”, or “sus”)"#,
),
})
}
}

#[derive(serde::Serialize, serde::Deserialize, Clone)]
pub struct KindSet(Vec<Kind>);

Expand All @@ -117,7 +96,20 @@ impl FromStr for KindSet {
let mut set = Vec::new();

for kind in s.split(',') {
let kind = Kind::from_str(kind)?;
let kind = match kind {
"heavy" => Kind::Heavy,
"light" => Kind::Light,
"curved" => Kind::Curved,
"knobby" => Kind::Knobby,
"emoji" => Kind::Emoji,
"outline" => Kind::Outline,
"dots" => Kind::Dots,
"blocks" => Kind::Blocks,
"sus" => Kind::Sus,
_ => anyhow::bail!(
r#"unknown pipe kind (expected “heavy”, “light”, “curved”, “knobby”, “emoji”, “outline”, “dots”, “blocks”, or “sus”)"#,
),
};

if !set.contains(&kind) {
set.push(kind);
Expand Down

0 comments on commit 615ab3a

Please sign in to comment.