Skip to content

Commit 220b943

Browse files
committed
disallow Rust 2018 idioms for clearer code
1 parent 3831937 commit 220b943

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ readme = "changelog.md"
1212
include = ["src/**/*", "LICENSE.md", "README.md", "CHANGELOG.md"]
1313

1414
[dependencies]
15-
serde = "1"
16-
serde_derive = "1"
15+
serde = { version = "1", features = ["std", "derive"] }
1716
serde_json = "1"
1817

1918
[dependencies.git2]

src/index.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl Index {
4545
}
4646

4747
/// Return the reference pointing to the state we have seen after calling `fetch_changes()`.
48-
pub fn last_seen_reference(&self) -> Result<Reference, GitError> {
48+
pub fn last_seen_reference(&self) -> Result<Reference<'_>, GitError> {
4949
self.repo.find_reference(self.seen_ref_name)
5050
}
5151

@@ -104,7 +104,7 @@ impl Index {
104104
CloneOptions {
105105
repository_url,
106106
fetch_options,
107-
}: CloneOptions,
107+
}: CloneOptions<'_>,
108108
) -> Result<Index, GitError> {
109109
let mut repo_did_exist = true;
110110
let repo = Repository::open(path.as_ref()).or_else(|err| {
@@ -265,10 +265,10 @@ impl Index {
265265
/// to either `Commit`s or `Tree`s.
266266
pub fn changes_from_objects(
267267
&self,
268-
from: &Object,
269-
to: &Object,
268+
from: &Object<'_>,
269+
to: &Object<'_>,
270270
) -> Result<Vec<Change>, GitError> {
271-
fn into_tree<'a>(repo: &'a Repository, obj: &Object) -> Result<Tree<'a>, GitError> {
271+
fn into_tree<'a>(repo: &'a Repository, obj: &Object<'_>) -> Result<Tree<'a>, GitError> {
272272
repo.find_tree(match obj.kind() {
273273
Some(ObjectType::Commit) => obj
274274
.as_commit()

src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
//! Have a look at the real-world usage to learn more about it:
44
//! [crates-io-cli](https://github.com/Byron/crates-io-cli-rs/blob/b7a39ad8ef68adb81b2d8a7e552cb0a2a73f7d5b/src/main.rs#L62)
55
#![forbid(missing_docs)]
6-
#[macro_use]
7-
extern crate serde_derive;
6+
#![deny(rust_2018_idioms)]
87

98
mod index;
109
mod version;

src/version.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub enum Change {
1414
}
1515

1616
impl fmt::Display for Change {
17-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
17+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1818
write!(
1919
f,
2020
"{}",
@@ -28,7 +28,7 @@ impl fmt::Display for Change {
2828
}
2929

3030
/// Pack all information we know about a change made to a version of a crate.
31-
#[derive(Clone, Serialize, Deserialize, Eq, PartialEq, Debug)]
31+
#[derive(Clone, serde::Serialize, serde::Deserialize, Eq, PartialEq, Debug)]
3232
pub struct CrateVersion {
3333
/// The crate name, i.e. `clap`.
3434
pub name: String,
@@ -48,7 +48,7 @@ pub struct CrateVersion {
4848
}
4949

5050
/// A single dependency of a specific crate version
51-
#[derive(Clone, Serialize, Deserialize, Ord, PartialOrd, Eq, PartialEq, Debug)]
51+
#[derive(Clone, serde::Serialize, serde::Deserialize, Ord, PartialOrd, Eq, PartialEq, Debug)]
5252
pub struct Dependency {
5353
/// The crate name
5454
pub name: String,

0 commit comments

Comments
 (0)