Skip to content

Commit 1d81171

Browse files
committed
Enable pedantic mode for Clippy
1 parent 8529ff2 commit 1d81171

3 files changed

Lines changed: 21 additions & 13 deletions

File tree

src/lib.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Create markdown tables for [Locatarr](https://github.com/Locatarr/Locatarr)
22
3+
#![warn(clippy::pedantic)]
4+
35
use itertools::Itertools;
46

57
use models::{Application, Applications};
@@ -10,26 +12,27 @@ pub mod models;
1012
///
1113
/// The resulting table is the minimum viable table and is not formatted in any way.
1214
pub fn generate_md_table(apps: &Applications) -> String {
13-
"| **Application** | **Description** | **Github** | **Reddit** |\n|-|-|-|-|\n".to_owned() +
14-
&apps.applications
15-
.iter()
16-
.sorted()
17-
.map(generate_md_row)
18-
.join("\n")
15+
"| **Application** | **Description** | **Github** | **Reddit** |\n|-|-|-|-|\n".to_owned()
16+
+ &apps
17+
.applications
18+
.iter()
19+
.sorted()
20+
.map(generate_md_row)
21+
.join("\n")
1922
}
2023

2124
/// Create one markdown table row from a single [Application]
2225
///
23-
/// Copies the [Application::name] and [Application::description] fields in, and transforms [Application::github_slug] and
24-
/// [Application::subreddit] into proper markdown links.
26+
/// Copies the [`Application::name`] and [`Application::description`] fields in, and transforms [`Application::github_slug`] and
27+
/// [`Application::subreddit`] into proper markdown links.
2528
fn generate_md_row(app: &Application) -> String {
2629
let github_link = match &app.github_slug {
27-
Some(slug) => format!("[{}](https://github.com/{})", slug, slug),
30+
Some(slug) => format!("[{slug}](https://github.com/{slug})"),
2831
None => String::new(),
2932
};
3033

3134
let subreddit_link = match &app.subreddit {
32-
Some(sub) => format!("[{}](https://reddit.com/{})", sub, sub),
35+
Some(sub) => format!("[{sub}](https://reddit.com/{sub})"),
3336
None => String::new(),
3437
};
3538

src/main.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![warn(clippy::pedantic)]
2+
13
use clap::Parser;
24
use std::{path::PathBuf, process::ExitCode};
35

@@ -51,5 +53,5 @@ fn main() -> ExitCode {
5153

5254
println!("{markdown_table}");
5355

54-
return 0.into();
56+
0.into()
5557
}

src/models.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! The models sub-crate holds all of the general purpose structs used throughout the library.
22
3+
use std::borrow::ToOwned;
4+
35
use serde::{Deserialize, Serialize};
46

57
/// Struct for the collection of a list of applications so that [serde] can deserialize a JSON
@@ -25,6 +27,7 @@ pub struct Application {
2527
impl Application {
2628
/// Create a new [Application] from various string references instead of owned strings
2729
#[allow(dead_code)] // Because I like this function here, but we aren't currently using it anywhere
30+
#[must_use]
2831
pub fn new_from_strs(
2932
name: &str,
3033
description: &str,
@@ -34,8 +37,8 @@ impl Application {
3437
Self {
3538
name: name.to_owned(),
3639
description: description.to_owned(),
37-
github_slug: github_slug.map(|s| s.to_owned()),
38-
subreddit: subreddit.map(|s| s.to_owned()),
40+
github_slug: github_slug.map(ToOwned::to_owned),
41+
subreddit: subreddit.map(ToOwned::to_owned),
3942
}
4043
}
4144
}

0 commit comments

Comments
 (0)