Skip to content

Commit

Permalink
refactor(report): Leverage derive_more
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Aug 7, 2019
1 parent a129fb3 commit e90a89e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 25 deletions.
27 changes: 21 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ bstr = "0.2"
log = "0.4"
env_logger = "0.6"
unicode-segmentation = "1.3.0"
derive_more = "0.15.0"

[dev-dependencies]
assert_fs = "0.10"
Expand Down
20 changes: 1 addition & 19 deletions src/report.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::borrow::Cow;
use std::io::{self, Write};

#[derive(Clone, Debug, serde::Serialize)]
#[derive(Clone, Debug, serde::Serialize, derive_more::From)]
#[serde(rename_all = "snake_case")]
#[serde(tag = "type")]
pub enum Message<'m> {
Expand All @@ -10,24 +10,6 @@ pub enum Message<'m> {
FilenameCorrection(FilenameCorrection<'m>),
}

impl<'m> From<BinaryFile<'m>> for Message<'m> {
fn from(msg: BinaryFile<'m>) -> Self {
Message::BinaryFile(msg)
}
}

impl<'m> From<Correction<'m>> for Message<'m> {
fn from(msg: Correction<'m>) -> Self {
Message::Correction(msg)
}
}

impl<'m> From<FilenameCorrection<'m>> for Message<'m> {
fn from(msg: FilenameCorrection<'m>) -> Self {
Message::FilenameCorrection(msg)
}
}

#[derive(Clone, Debug, serde::Serialize)]
pub struct BinaryFile<'m> {
pub path: &'m std::path::Path,
Expand Down

0 comments on commit e90a89e

Please sign in to comment.