Skip to content

Commit 94c4346

Browse files
committed
cargo clippy --fix
1 parent 8b074a2 commit 94c4346

File tree

17 files changed

+28
-35
lines changed

17 files changed

+28
-35
lines changed

build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fn main() {
1818
hash.trim(),
1919
date.trim_matches('\'')
2020
);
21-
println!("cargo:rustc-env=VERSION={}", ver);
21+
println!("cargo:rustc-env=VERSION={ver}");
2222
} else {
2323
println!("cargo:rustc-env=VERSION={}", env!("CARGO_PKG_VERSION"));
2424
}

src/blocks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ impl CommonApi {
220220
pub fn get_icon(&self, icon: &str) -> Result<String> {
221221
self.shared_config
222222
.get_icon(icon)
223-
.or_error(|| format!("Icon '{}' not found", icon))
223+
.or_error(|| format!("Icon '{icon}' not found"))
224224
}
225225

226226
/// Repeatedly call provided async function until it succeeds.

src/blocks/battery/apc_ups.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,17 @@ impl PropertyMap {
2626
) -> Result<T> {
2727
let stat = self
2828
.get(property_name)
29-
.or_error(|| format!("{} not in apc ups data", property_name))?;
29+
.or_error(|| format!("{property_name} not in apc ups data"))?;
3030
let (value, unit) = stat
3131
.split_once(' ')
32-
.or_error(|| format!("could not split {}", property_name))?;
32+
.or_error(|| format!("could not split {property_name}"))?;
3333
if unit == required_unit {
3434
value
3535
.parse::<T>()
3636
.map_err(|_| Error::new("Could not parse data"))
3737
} else {
3838
Err(Error::new(format!(
39-
"Expected unit for {} are {}, but got {}",
40-
property_name, required_unit, unit
39+
"Expected unit for {property_name} are {required_unit}, but got {unit}"
4140
)))
4241
}
4342
}

src/blocks/custom_dbus.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ pub async fn run(config: Config, mut api: CommonApi) -> Result<()> {
156156

157157
async fn dbus_conn() -> Result<zbus::Connection> {
158158
let dbus_interface_name = match env::var("I3RS_DBUS_NAME") {
159-
Ok(v) => format!("{}.{}", DBUS_NAME, v),
159+
Ok(v) => format!("{DBUS_NAME}.{v}"),
160160
Err(_) => DBUS_NAME.to_string(),
161161
};
162162

src/blocks/tea_timer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ pub async fn run(config: Config, mut api: CommonApi) -> Result<()> {
6363

6464
widget.set_values(map!(
6565
"icon" => Value::icon(api.get_icon("tea")?),
66-
[if is_timer_active] "hours" => Value::text(format!("{:02}", hours)),
67-
[if is_timer_active] "minutes" => Value::text(format!("{:02}", minutes)),
68-
[if is_timer_active] "seconds" => Value::text(format!("{:02}", seconds)),
66+
[if is_timer_active] "hours" => Value::text(format!("{hours:02}")),
67+
[if is_timer_active] "minutes" => Value::text(format!("{minutes:02}")),
68+
[if is_timer_active] "seconds" => Value::text(format!("{seconds:02}")),
6969
));
7070

7171
api.set_widget(&widget).await?;

src/blocks/temperature.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,7 @@ pub async fn run(config: Config, mut api: CommonApi) -> Result<()> {
149149
vals.push(config.scale.from_celsius(value));
150150
} else {
151151
eprintln!(
152-
"Temperature ({}) outside of range ([-100, 150])",
153-
value
152+
"Temperature ({value}) outside of range ([-100, 150])"
154153
);
155154
}
156155
}

src/blocks/weather/open_weather_map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ impl WeatherProvider for Service {
8686
.as_ref()
8787
.map(|(lat, lon)| format!("lat={lat}&lon={lon}"))
8888
})
89-
.or_else(|| self.config.city_id.as_ref().map(|x| format!("id={}", x)))
90-
.or_else(|| self.config.place.as_ref().map(|x| format!("q={}", x)))
89+
.or_else(|| self.config.city_id.as_ref().map(|x| format!("id={x}")))
90+
.or_else(|| self.config.place.as_ref().map(|x| format!("q={x}")))
9191
.error("no location was provided")?;
9292

9393
// Refer to https://openweathermap.org/current

src/click.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ impl ClickHandler {
4444
} else {
4545
spawn_shell(cmd)
4646
}
47-
.or_error(|| {
48-
format!("'{:?}' button handler: Failed to run '{}", button, cmd)
49-
})?;
47+
.or_error(|| format!("'{button:?}' button handler: Failed to run '{cmd}"))?;
5048
}
5149
PostActions {
5250
pass: entry.pass,

src/errors.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,17 +165,17 @@ impl fmt::Display for Error {
165165
write!(f, " in {}", block.0)?;
166166

167167
if let Some(message) = &self.message {
168-
write!(f, ": {}", message)?;
168+
write!(f, ": {message}")?;
169169
}
170170

171171
if let Some(cause) = &self.cause {
172-
write!(f, ". (Cause: {})", cause)?;
172+
write!(f, ". (Cause: {cause})")?;
173173
}
174174
}
175175
None => {
176176
f.write_str(self.message.as_deref().unwrap_or("Error"))?;
177177
if let Some(cause) = &self.cause {
178-
write!(f, ". (Cause: {})", cause)?;
178+
write!(f, ". (Cause: {cause})")?;
179179
}
180180
}
181181
}

src/formatting/formatter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ pub fn new_formatter(name: &str, args: &[String]) -> Result<Box<dyn Formatter>>
128128
}
129129
"eng" => Ok(Box::new(EngFormatter(EngFixConfig::from_args(args)?))),
130130
"fix" => Ok(Box::new(FixFormatter(EngFixConfig::from_args(args)?))),
131-
_ => Err(Error::new(format!("Unknown formatter: '{}'", name))),
131+
_ => Err(Error::new(format!("Unknown formatter: '{name}'"))),
132132
}
133133
}
134134

0 commit comments

Comments
 (0)