Skip to content

Commit 8728980

Browse files
committed
cargo clippy fixes in cmsis-cli
1 parent 275dbb6 commit 8728980

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

rust/cmsis-cli/src/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ impl Config {
6868
}
6969
match OpenOptions::new()
7070
.create(true)
71+
.truncate(true)
7172
.write(true)
7273
.open(&self.vidx_list)
7374
{

rust/cmsis-cli/src/lib.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub fn install_args() -> App<'static, 'static> {
6262
)
6363
}
6464

65-
pub fn install_command<'a>(conf: &Config, args: &ArgMatches<'a>) -> Result<(), Error> {
65+
pub fn install_command(conf: &Config, args: &ArgMatches<'_>) -> Result<(), Error> {
6666
let pdsc_list: Vec<_> = args
6767
.values_of("PDSC")
6868
.unwrap()
@@ -91,7 +91,7 @@ pub fn update_args<'a, 'b>() -> App<'a, 'b> {
9191
.version("0.1.0")
9292
}
9393

94-
pub fn update_command<'a>(conf: &Config, _: &ArgMatches<'a>) -> Result<(), Error> {
94+
pub fn update_command(conf: &Config, _: &ArgMatches<'_>) -> Result<(), Error> {
9595
let vidx_list = conf.read_vidx_list();
9696
for url in vidx_list.iter() {
9797
log::info!("Updating registry from `{}`", url);
@@ -136,7 +136,7 @@ pub fn dump_devices_args<'a, 'b>() -> App<'a, 'b> {
136136
)
137137
}
138138

139-
pub fn dump_devices_command<'a>(c: &Config, args: &ArgMatches<'a>) -> Result<(), Error> {
139+
pub fn dump_devices_command(c: &Config, args: &ArgMatches<'_>) -> Result<(), Error> {
140140
let files = args
141141
.value_of("INPUT")
142142
.map(|input| vec![Path::new(input).to_path_buf()]);
@@ -175,27 +175,27 @@ pub fn check_args<'a, 'b>() -> App<'a, 'b> {
175175
)
176176
}
177177

178-
pub fn check_command<'a>(_: &Config, args: &ArgMatches<'a>) -> Result<(), Error> {
178+
pub fn check_command(_: &Config, args: &ArgMatches<'_>) -> Result<(), Error> {
179179
let filename = args.value_of("INPUT").unwrap();
180180
match Package::from_path(Path::new(filename)) {
181181
Ok(c) => {
182182
log::info!("Parsing succedded");
183-
log::info!("{} Valid Conditions", c.conditions.0.iter().count());
183+
log::info!("{} Valid Conditions", c.conditions.0.len());
184184
let cond_lookup = c.make_condition_lookup();
185185
let mut num_components = 0;
186186
let mut num_files = 0;
187-
for &Component {
188-
ref class,
189-
ref group,
190-
ref condition,
191-
ref files,
187+
for Component {
188+
class,
189+
group,
190+
condition,
191+
files,
192192
..
193193
} in c.make_components().iter()
194194
{
195195
num_components += 1;
196-
num_files += files.iter().count();
196+
num_files += files.len();
197197
if let Some(ref cond_name) = condition {
198-
if cond_lookup.get(cond_name.as_str()).is_none() {
198+
if !cond_lookup.contains_key(cond_name.as_str()) {
199199
log::warn!(
200200
"Component {}::{} references an unknown condition '{}'",
201201
class,
@@ -204,14 +204,14 @@ pub fn check_command<'a>(_: &Config, args: &ArgMatches<'a>) -> Result<(), Error>
204204
);
205205
}
206206
}
207-
for &FileRef {
208-
ref path,
209-
ref condition,
207+
for FileRef {
208+
path,
209+
condition,
210210
..
211211
} in files.iter()
212212
{
213213
if let Some(ref cond_name) = condition {
214-
if cond_lookup.get(cond_name.as_str()).is_none() {
214+
if !cond_lookup.contains_key(cond_name.as_str()) {
215215
log::warn!(
216216
"File {:?} Component {}::{} references an unknown condition '{}'",
217217
path,

0 commit comments

Comments
 (0)