Skip to content

Commit 5376edc

Browse files
committed
clippy fix
1 parent ca4ddb9 commit 5376edc

3 files changed

Lines changed: 5 additions & 7 deletions

File tree

micropb-gen/src/config.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -637,12 +637,11 @@ fn substitute_param<'a>(
637637
pat: &str,
638638
t: Option<impl ToString>,
639639
) -> Cow<'a, str> {
640-
if let Some(t) = t {
641-
if typestr.find(pat).is_some() {
640+
if let Some(t) = t
641+
&& typestr.find(pat).is_some() {
642642
let t = t.to_string();
643643
return typestr.replace(pat, &t).into();
644644
}
645-
}
646645
typestr
647646
}
648647

micropb-gen/src/generator/location.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub(crate) fn add_location_comments(
6464
};
6565

6666
let path = &location.path;
67-
if path.len() % 2 != 0 {
67+
if !path.len().is_multiple_of(2) {
6868
return;
6969
}
7070
let segments: Vec<_> = path.chunks(2).map(|chunk| (chunk[0], chunk[1])).collect();

micropb-gen/src/generator/type_spec.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,13 +475,12 @@ impl<'proto> TypeSpec<'proto> {
475475
/// generator options). Even though strings and bytes are also length-delimited, we don't need
476476
/// to cache them because calculating their lengths is trivial.
477477
pub(crate) fn generate_cache_type(&self, ctx: &Context<'proto>) -> Option<TokenStream> {
478-
if let TypeSpec::Message(tname) = self {
479-
if ctx.params.cache_extern_types || !ctx.params.extern_paths.contains_key(*tname) {
478+
if let TypeSpec::Message(tname) = self
479+
&& (ctx.params.cache_extern_types || !ctx.params.extern_paths.contains_key(*tname)) {
480480
let cache_name = (*tname).to_owned() + "._Cache";
481481
let cache_type = ctx.resolve_type_name(&cache_name);
482482
return Some(cache_type);
483483
}
484-
}
485484
None
486485
}
487486

0 commit comments

Comments
 (0)