Skip to content

Commit ec1442c

Browse files
committed
lints
1 parent 731a467 commit ec1442c

File tree

4 files changed

+25
-25
lines changed

4 files changed

+25
-25
lines changed

src/cli.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl Cli {
4242
None
4343
}
4444

45-
pub fn get_settings(&self) -> Settings {
45+
#[must_use] pub fn get_settings(&self) -> Settings {
4646
let mut settings = get_configuration().unwrap_or_else(|_| Settings::default());
4747

4848
if let Some(seconds) = self.get_seconds() {
@@ -56,7 +56,7 @@ impl Cli {
5656
settings
5757
}
5858

59-
pub fn get_action(&self) -> Actions {
59+
#[must_use] pub fn get_action(&self) -> Actions {
6060
if self.toggle {
6161
return Actions::Toggle;
6262
}

src/path.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub enum File {
1515
}
1616

1717
impl File {
18-
pub fn new(path: PathBuf) -> Option<Self> {
18+
#[must_use] pub fn new(path: PathBuf) -> Option<Self> {
1919
if !path.exists() {
2020
None
2121
} else if path.is_dir() {
@@ -43,8 +43,8 @@ impl File {
4343
impl Display for File {
4444
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4545
match self {
46-
Self::Image(image) => write!(f, "{}", image),
47-
Self::Folder(folder) => write!(f, "{}", folder),
46+
Self::Image(image) => write!(f, "{image}"),
47+
Self::Folder(folder) => write!(f, "{folder}"),
4848
}
4949
}
5050
}
@@ -82,7 +82,7 @@ pub struct ImagePath {
8282
}
8383

8484
impl ImagePath {
85-
pub fn new(path: PathBuf) -> Option<Self> {
85+
#[must_use] pub fn new(path: PathBuf) -> Option<Self> {
8686
if !path.exists() || path.is_dir() {
8787
None
8888
} else {
@@ -104,7 +104,7 @@ impl ImagePath {
104104
/// If it is a file it must be contained in a folder that is contained in the wallpaper directory.
105105
///
106106
/// Example:
107-
/// wallpaper_dir
107+
/// `wallpaper_dir`
108108
/// |--- folder1
109109
/// | |--- wallpaper1
110110
/// |-- wallpaper2
@@ -125,7 +125,7 @@ impl ImagePath {
125125
is_animated
126126
}
127127

128-
/// Helper function for is_animated.
128+
/// Helper function for `is_animated`.
129129
fn check_if_animated(&mut self, settings: &Settings) -> bool {
130130
if let Some(parent) = self.path.parent() {
131131
if self.path.is_dir() {
@@ -154,18 +154,18 @@ impl ImagePath {
154154
/// # Panics
155155
///
156156
/// If the path is not an animated wallpaper it may panic.
157-
pub fn get_animated_wallpaper_name(&self) -> String {
157+
#[must_use] pub fn get_animated_wallpaper_name(&self) -> String {
158158
self.animated_info.as_ref().unwrap().animated_folder.clone()
159159
}
160160

161-
pub fn get_animated_number(&self) -> Option<u32> {
161+
#[must_use] pub fn get_animated_number(&self) -> Option<u32> {
162162
if let Some(info) = self.animated_info.as_ref() {
163163
return Some(info.animated_number);
164164
}
165165
None
166166
}
167167

168-
pub fn path(&self) -> &Path {
168+
#[must_use] pub fn path(&self) -> &Path {
169169
&self.path
170170
}
171171

@@ -265,7 +265,7 @@ impl AnimatedInfo {
265265
.expect("failed to convert file name to str")
266266
.chars()
267267
.rev()
268-
.take_while(|c| c.is_ascii_digit())
268+
.take_while(char::is_ascii_digit)
269269
.collect::<String>()
270270
.chars()
271271
.rev()

src/setup.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ pub fn run(settings: Settings, action: Actions) {
1515
Ok(wallpaper) => {
1616
let path = wallpaper.to_string();
1717
if let Err(err) = update_wallpaper(&settings, &path) {
18-
eprintln!("Error, {}", err);
18+
eprintln!("Error, {err}");
1919
}
2020
}
21-
Err(err) => eprintln!("Error, {}", err),
21+
Err(err) => eprintln!("Error, {err}"),
2222
},
2323
Actions::Get => match get_next_wallpaper(&settings) {
24-
Ok(wallpaper) => println!("{}", wallpaper),
25-
Err(err) => eprintln!("Error, {}", err),
24+
Ok(wallpaper) => println!("{wallpaper}"),
25+
Err(err) => eprintln!("Error, {err}"),
2626
},
2727
}
2828
}
@@ -38,8 +38,8 @@ fn run_daemon(settings: Settings) {
3838
.stderr(stderr); // Redirect stderr
3939

4040
match daemonize.start() {
41-
Ok(_) => launch_wallpaper_loop(settings),
42-
Err(e) => eprintln!("Error, {}", e),
41+
Ok(()) => launch_wallpaper_loop(settings),
42+
Err(e) => eprintln!("Error, {e}"),
4343
}
4444
}
4545

@@ -49,21 +49,21 @@ fn launch_wallpaper_loop(settings: Settings) {
4949
Ok(mut wallpaper) => {
5050
let path = wallpaper.to_string();
5151
if let Err(err) = update_wallpaper(&settings, &path) {
52-
eprintln!("Error, {}", err);
52+
eprintln!("Error, {err}");
5353
thread::sleep(Duration::from_secs(settings.sleep_time));
5454
} else {
5555
let sleep_time = match wallpaper.get_sleep_time(&settings) {
5656
Ok(seconds) => seconds,
5757
Err(err) => {
58-
eprintln!("Error, {}", err);
58+
eprintln!("Error, {err}");
5959
settings.sleep_time
6060
}
6161
};
6262

6363
thread::sleep(Duration::from_secs(sleep_time));
6464
}
6565
}
66-
Err(err) => eprintln!("Error, {}", err),
66+
Err(err) => eprintln!("Error, {err}"),
6767
}
6868
}
6969
}

src/wallpaper.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ pub fn get_random_wallpaper(settings: &Settings) -> Result<File> {
5353
let files = read_dir(settings.wallpaper_dir.clone())?
5454
.filter_map(|entry| {
5555
if let Ok(entry) = entry {
56-
if !entry
56+
if entry
5757
.file_name()
5858
.to_str()
5959
.expect("failed to convert file name to str")
6060
.starts_with('.')
6161
{
62-
Some(entry)
63-
} else {
6462
None
63+
} else {
64+
Some(entry)
6565
}
6666
} else {
6767
None
@@ -121,7 +121,7 @@ pub fn get_next_animated_wallpaper(settings: &Settings, path: &File) -> Result<O
121121
}
122122
}
123123

124-
let base_name = format!("{name}{}", next_index);
124+
let base_name = format!("{name}{next_index}");
125125

126126
let a = read_dir(format!("{}/{name}", settings.wallpaper_dir))?.find(|s| {
127127
if let Ok(s) = s {

0 commit comments

Comments
 (0)