mirror of
https://github.com/tealdeer-rs/tealdeer.git
synced 2026-08-24 00:54:17 +02:00
Fix clippy warnings (#105)
This commit is contained in:
parent
54464da510
commit
a594b0013e
3 changed files with 28 additions and 28 deletions
|
|
@ -37,14 +37,14 @@ pub enum RawColor {
|
|||
impl From<RawColor> for Color {
|
||||
fn from(raw_color: RawColor) -> Self {
|
||||
match raw_color {
|
||||
RawColor::Black => Color::Black,
|
||||
RawColor::Red => Color::Red,
|
||||
RawColor::Green => Color::Green,
|
||||
RawColor::Yellow => Color::Yellow,
|
||||
RawColor::Blue => Color::Blue,
|
||||
RawColor::Purple => Color::Purple,
|
||||
RawColor::Cyan => Color::Cyan,
|
||||
RawColor::White => Color::White,
|
||||
RawColor::Black => Self::Black,
|
||||
RawColor::Red => Self::Red,
|
||||
RawColor::Green => Self::Green,
|
||||
RawColor::Yellow => Self::Yellow,
|
||||
RawColor::Blue => Self::Blue,
|
||||
RawColor::Purple => Self::Purple,
|
||||
RawColor::Cyan => Self::Cyan,
|
||||
RawColor::White => Self::White,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,16 +11,16 @@ pub enum TealdeerError {
|
|||
|
||||
impl From<ReqwestError> for TealdeerError {
|
||||
fn from(err: ReqwestError) -> Self {
|
||||
TealdeerError::UpdateError(format!("HTTP error: {}", err.to_string()))
|
||||
Self::UpdateError(format!("HTTP error: {}", err.to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for TealdeerError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
TealdeerError::CacheError(e) => write!(f, "CacheError: {}", e),
|
||||
TealdeerError::ConfigError(e) => write!(f, "ConfigError: {}", e),
|
||||
TealdeerError::UpdateError(e) => write!(f, "UpdateError: {}", e),
|
||||
Self::CacheError(e) => write!(f, "CacheError: {}", e),
|
||||
Self::ConfigError(e) => write!(f, "ConfigError: {}", e),
|
||||
Self::UpdateError(e) => write!(f, "UpdateError: {}", e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
32
src/types.rs
32
src/types.rs
|
|
@ -18,11 +18,11 @@ pub enum OsType {
|
|||
impl fmt::Display for OsType {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
OsType::Linux => write!(f, "Linux"),
|
||||
OsType::OsX => write!(f, "macOS / BSD"),
|
||||
OsType::SunOs => write!(f, "SunOS"),
|
||||
OsType::Windows => write!(f, "Windows"),
|
||||
OsType::Other => write!(f, "Unknown OS"),
|
||||
Self::Linux => write!(f, "Linux"),
|
||||
Self::OsX => write!(f, "macOS / BSD"),
|
||||
Self::SunOs => write!(f, "SunOS"),
|
||||
Self::Windows => write!(f, "Windows"),
|
||||
Self::Other => write!(f, "Unknown OS"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -43,23 +43,23 @@ impl<'a> From<&'a str> for LineType {
|
|||
let trimmed: &str = line.trim_end();
|
||||
let mut chars = trimmed.chars();
|
||||
match chars.next() {
|
||||
None => LineType::Empty,
|
||||
Some('#') => LineType::Title(
|
||||
None => Self::Empty,
|
||||
Some('#') => Self::Title(
|
||||
trimmed
|
||||
.trim_start_matches(|chr: char| chr == '#' || chr.is_whitespace())
|
||||
.into(),
|
||||
),
|
||||
Some('>') => LineType::Description(
|
||||
Some('>') => Self::Description(
|
||||
trimmed
|
||||
.trim_start_matches(|chr: char| chr == '>' || chr.is_whitespace())
|
||||
.into(),
|
||||
),
|
||||
Some(' ') => LineType::ExampleCode(
|
||||
Some(' ') => Self::ExampleCode(
|
||||
trimmed
|
||||
.trim_start_matches(char::is_whitespace)
|
||||
.into(),
|
||||
),
|
||||
_ => LineType::ExampleText(trimmed.into()),
|
||||
_ => Self::ExampleText(trimmed.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -71,28 +71,28 @@ impl LineType {
|
|||
let trimmed = line.trim();
|
||||
let mut chars = trimmed.chars();
|
||||
match chars.next() {
|
||||
None => LineType::Empty,
|
||||
Some('#') => LineType::Title(
|
||||
None => Self::Empty,
|
||||
Some('#') => Self::Title(
|
||||
trimmed
|
||||
.trim_start_matches(|chr: char| chr == '#' || chr.is_whitespace())
|
||||
.into(),
|
||||
),
|
||||
Some('>') => LineType::Description(
|
||||
Some('>') => Self::Description(
|
||||
trimmed
|
||||
.trim_start_matches(|chr: char| chr == '>' || chr.is_whitespace())
|
||||
.into(),
|
||||
),
|
||||
Some('-') => LineType::ExampleText(
|
||||
Some('-') => Self::ExampleText(
|
||||
trimmed
|
||||
.trim_start_matches(|chr: char| chr == '-' || chr.is_whitespace())
|
||||
.into(),
|
||||
),
|
||||
Some('`') if chars.last() == Some('`') => LineType::ExampleCode(
|
||||
Some('`') if chars.last() == Some('`') => Self::ExampleCode(
|
||||
trimmed
|
||||
.trim_matches(|chr: char| chr == '`' || chr.is_whitespace())
|
||||
.into(),
|
||||
),
|
||||
_ => LineType::Other(trimmed.into()),
|
||||
_ => Self::Other(trimmed.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue