Skip to content

Commit

Permalink
Fix warnings and clippy errors
Browse files Browse the repository at this point in the history
type: reform
  • Loading branch information
casey committed Jul 3, 2021
1 parent 2346c30 commit 379a001
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 34 deletions.
11 changes: 3 additions & 8 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,9 @@ jobs:
target
key: cargo-${{ env.CACHE_KEY }}-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}

- name: Install Stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{matrix.target}}
profile: minimal
components: clippy, rustfmt
override: true
- name: Install Rust Toolchain Components
run: |
rustup component add clippy rustfmt
- name: Info
run: |
Expand Down
1 change: 1 addition & 0 deletions rust-toolchain
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.51.0
4 changes: 2 additions & 2 deletions src/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const TI: u64 = GI << 10;
const PI: u64 = TI << 10;
const EI: u64 = PI << 10;

#[serde(transparent)]
#[derive(Debug, PartialEq, Copy, Clone, PartialOrd, Ord, Eq, Serialize, Deserialize, Default)]
#[serde(transparent)]
pub(crate) struct Bytes(pub(crate) u64);

impl Bytes {
Expand Down Expand Up @@ -89,7 +89,7 @@ impl FromStr for Bytes {
_ => {
return Err(Error::ByteSuffix {
text: text.to_owned(),
suffix: suffix.to_owned(),
suffix: suffix.clone(),
})
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl Env {
.and_then(|width| width.parse::<usize>().ok());

if let Some(width) = width {
app = app.set_term_width(width)
app = app.set_term_width(width);
}

app
Expand Down
2 changes: 1 addition & 1 deletion src/file_path.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::common::*;

#[serde(transparent)]
#[derive(Deserialize, Serialize, Debug, PartialEq, Clone, Ord, PartialOrd, Eq)]
#[serde(transparent)]
pub(crate) struct FilePath {
components: Vec<String>,
}
Expand Down
2 changes: 1 addition & 1 deletion src/linter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ impl Linter {
}

pub(crate) fn allow(&mut self, allowed: impl IntoIterator<Item = Lint>) {
self.allowed.extend(allowed)
self.allowed.extend(allowed);
}

pub(crate) fn is_allowed(&self, lint: Lint) -> bool {
Expand Down
2 changes: 1 addition & 1 deletion src/md5_digest.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::common::*;

#[serde(transparent)]
#[derive(Deserialize, Serialize, Debug, Eq, PartialEq, Copy, Clone)]
#[serde(transparent)]
pub(crate) struct Md5Digest {
#[serde(with = "SerHex::<serde_hex::Strict>")]
bytes: [u8; 16],
Expand Down
2 changes: 1 addition & 1 deletion src/mode.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::common::*;

#[serde(untagged)]
#[derive(Deserialize, Serialize, Debug, PartialEq, Clone)]
#[serde(untagged)]
pub(crate) enum Mode {
Single {
length: Bytes,
Expand Down
2 changes: 1 addition & 1 deletion src/output_stream.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::common::*;

pub(crate) struct OutputStream {
active: bool,
stream: Box<dyn Write>,
style: bool,
term: bool,
active: bool,
}

impl OutputStream {
Expand Down
2 changes: 1 addition & 1 deletion src/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ mod tests {

#[test]
fn variants() {
assert_eq!(Shell::VARIANTS, clap::Shell::variants())
assert_eq!(Shell::VARIANTS, clap::Shell::variants());
}
}
20 changes: 9 additions & 11 deletions src/subcommand/torrent/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,7 @@ impl Create {

if let OutputTarget::Path(path) = &output {
if !self.force && path.exists() {
return Err(Error::OutputExists {
path: path.to_owned(),
});
return Err(Error::OutputExists { path: path.clone() });
}
}

Expand Down Expand Up @@ -1151,7 +1149,7 @@ mod tests {
length: Bytes(3),
md5sum: None,
}
)
);
}

#[test]
Expand Down Expand Up @@ -1182,7 +1180,7 @@ mod tests {
length: Bytes(4),
md5sum: None,
}
)
);
}

#[test]
Expand Down Expand Up @@ -1213,7 +1211,7 @@ mod tests {
length: Bytes(4),
md5sum: None,
}
)
);
}

#[test]
Expand Down Expand Up @@ -1258,7 +1256,7 @@ mod tests {
},
],
}
)
);
}

#[test]
Expand All @@ -1285,7 +1283,7 @@ mod tests {
length: Bytes(3),
md5sum: None,
}
)
);
}

#[test]
Expand Down Expand Up @@ -1319,7 +1317,7 @@ mod tests {
length: Bytes(3),
md5sum: None,
}
)
);
}

#[test]
Expand All @@ -1346,7 +1344,7 @@ mod tests {
length: Bytes(0),
md5sum: None,
}
)
);
}

#[test]
Expand All @@ -1367,7 +1365,7 @@ mod tests {
env.assert_ok();
let metainfo = env.load_metainfo("foo.torrent");
assert_eq!(metainfo.info.pieces.count(), 0);
assert_eq!(metainfo.info.mode, Mode::Multiple { files: Vec::new() })
assert_eq!(metainfo.info.mode, Mode::Multiple { files: Vec::new() });
}

#[test]
Expand Down
8 changes: 4 additions & 4 deletions src/test_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ macro_rules! test_env {

pub(crate) struct TestEnv {
env: Env,
#[allow(unused)]
tempdir: TempDir,
err: Capture,
out: Capture,
#[allow(unused)]
tempdir: TempDir,
}

impl TestEnv {
pub(crate) fn new(tempdir: TempDir, env: Env, err: Capture, out: Capture) -> TestEnv {
Self {
tempdir,
err,
env,
err,
out,
tempdir,
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/torrent_summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ impl TorrentSummary {

fn torrent_summary_data(&self) -> TorrentSummaryJson {
let (file_count, files) = match &self.metainfo.info.mode {
Mode::Single { .. } => (1, vec![self.metainfo.info.name.to_owned()]),
Mode::Single { .. } => (1, vec![self.metainfo.info.name.clone()]),
Mode::Multiple { files } => (
files.len(),
files
Expand All @@ -197,7 +197,7 @@ impl TorrentSummary {
};

TorrentSummaryJson {
name: self.metainfo.info.name.to_owned(),
name: self.metainfo.info.name.clone(),
comment: self.metainfo.comment.clone(),
creation_date: self.metainfo.creation_date,
created_by: self.metainfo.created_by.clone(),
Expand Down

0 comments on commit 379a001

Please sign in to comment.