diff --git a/compiler/src/compiler/util.rs b/compiler/src/compiler/util.rs index 3ecbac8..7d92f30 100644 --- a/compiler/src/compiler/util.rs +++ b/compiler/src/compiler/util.rs @@ -45,6 +45,12 @@ pub struct TypePathMap { type_path_by_name: HashMap, } +impl Default for TypePathMap { + fn default() -> Self { + Self::new() + } +} + impl TypePathMap { pub fn new() -> Self { Self { diff --git a/compiler/src/gen/base/enum.rs b/compiler/src/gen/base/enum.rs index 8d05a10..c018340 100644 --- a/compiler/src/gen/base/enum.rs +++ b/compiler/src/gen/base/enum.rs @@ -31,8 +31,8 @@ use crate::gen::base::structure::Utilities; use crate::gen::template::Template; use itertools::Itertools; -pub fn generate<'fragment, 'variable, U: Utilities>( - mut template: Template<'fragment, 'variable>, +pub fn generate<'variable, U: Utilities>( + mut template: Template<'_, 'variable>, e: &'variable Enum, ) -> String { template diff --git a/compiler/src/gen/base/message.rs b/compiler/src/gen/base/message.rs index 59e39f9..ffabc50 100644 --- a/compiler/src/gen/base/message.rs +++ b/compiler/src/gen/base/message.rs @@ -95,8 +95,8 @@ pub fn gen_msg_field_decl( scope.var("type", msg_type).render("decl", &["field"]).unwrap() } -pub fn generate<'fragment, 'variable, U: Utilities, T: TypeMapper>( - mut template: Template<'fragment, 'variable>, +pub fn generate<'variable, U: Utilities, T: TypeMapper>( + mut template: Template<'_, 'variable>, msg: &'variable Message, type_path_by_name: &TypePathMapper, ) -> String { diff --git a/compiler/src/gen/base/message_from_slice.rs b/compiler/src/gen/base/message_from_slice.rs index 82529fa..aed82dc 100644 --- a/compiler/src/gen/base/message_from_slice.rs +++ b/compiler/src/gen/base/message_from_slice.rs @@ -156,8 +156,8 @@ pub fn generate_from_slice_impl( .unwrap() } -pub fn generate<'fragment, 'variable, U: Utilities, T: TypeMapper>( - mut template: Template<'fragment, 'variable>, +pub fn generate<'variable, U: Utilities, T: TypeMapper>( + mut template: Template<'_, 'variable>, msg: &'variable Message, type_path_by_name: &TypePathMapper, ) -> String { diff --git a/compiler/src/gen/base/message_write.rs b/compiler/src/gen/base/message_write.rs index 4d5d363..d77201d 100644 --- a/compiler/src/gen/base/message_write.rs +++ b/compiler/src/gen/base/message_write.rs @@ -57,8 +57,8 @@ fn gen_field_write_impl( } } -pub fn generate<'fragment, 'variable, U: Utilities, T: TypeMapper>( - mut template: Template<'fragment, 'variable>, +pub fn generate<'variable, U: Utilities, T: TypeMapper>( + mut template: Template<'_, 'variable>, msg: &'variable Message, type_path_by_name: &TypePathMapper, ) -> String { diff --git a/compiler/src/gen/base/structure.rs b/compiler/src/gen/base/structure.rs index de51e13..562de42 100644 --- a/compiler/src/gen/base/structure.rs +++ b/compiler/src/gen/base/structure.rs @@ -230,8 +230,8 @@ pub struct Templates<'fragment, 'variable> { pub template: Template<'fragment, 'variable>, } -pub fn generate<'fragment, 'variable, U: Utilities, T: TypeMapper>( - templates: Templates<'fragment, 'variable>, +pub fn generate<'variable, U: Utilities, T: TypeMapper>( + templates: Templates<'_, 'variable>, s: &'variable Structure, type_path_by_name: &TypePathMapper, ) -> String { diff --git a/compiler/src/gen/base/union.rs b/compiler/src/gen/base/union.rs index 07bafd0..a5699b9 100644 --- a/compiler/src/gen/base/union.rs +++ b/compiler/src/gen/base/union.rs @@ -138,8 +138,8 @@ fn gen_union_as_getters( template.scope().var("cases", cases).render("", &["getters"]).unwrap() } -pub fn generate<'fragment, 'variable, U: Utilities, T: TypeMapper>( - mut template: Template<'fragment, 'variable>, +pub fn generate<'variable, U: Utilities, T: TypeMapper>( + mut template: Template<'_, 'variable>, u: &'variable Union, type_path_by_name: &'variable TypePathMapper, ) -> String { diff --git a/compiler/src/gen/swift/message.rs b/compiler/src/gen/swift/message.rs index 83585bd..7a19d5e 100644 --- a/compiler/src/gen/swift/message.rs +++ b/compiler/src/gen/swift/message.rs @@ -80,7 +80,7 @@ fn gen_initializer(template: &Template, msg: &Message, type_path_by_name: &TypeP .fields .iter() .map(|field| gen_msg_field_decl::(field, template, type_path_by_name)) - .map(|v| format!("{}", &v[..v.len() - 1])) + .map(|v| v[..v.len() - 1].to_string()) .join(", "); let initializers = msg .fields diff --git a/compiler/src/gen/swift/solver.rs b/compiler/src/gen/swift/solver.rs index 2c5073d..f11ac36 100644 --- a/compiler/src/gen/swift/solver.rs +++ b/compiler/src/gen/swift/solver.rs @@ -37,6 +37,12 @@ pub struct SwiftImportSolver { import_map: HashMap, Protocol)>, } +impl Default for SwiftImportSolver { + fn default() -> Self { + Self::new() + } +} + impl SwiftImportSolver { pub fn new() -> Self { Self { diff --git a/compiler/src/gen/template/util.rs b/compiler/src/gen/template/util.rs index cf4da81..2ac4cfd 100644 --- a/compiler/src/gen/template/util.rs +++ b/compiler/src/gen/template/util.rs @@ -30,6 +30,7 @@ use itertools::Itertools; use regex::Regex; use std::borrow::Cow; +#[allow(clippy::enum_variant_names)] enum Convention { PascalCase, SnakeCase, diff --git a/compiler/src/interface.rs b/compiler/src/interface.rs index 60325f9..2fba9be 100644 --- a/compiler/src/interface.rs +++ b/compiler/src/interface.rs @@ -42,6 +42,12 @@ pub struct Loader { imported_models: Vec<(String, model::Protocol)>, } +impl Default for Loader { + fn default() -> Self { + Self::new() + } +} + impl Loader { pub fn new() -> Self { Self { @@ -151,7 +157,7 @@ impl<'a> Protoc<'a> { ) -> Result, Error> { let file_header = self .file_header - .map(|v| std::fs::read_to_string(v)) + .map(std::fs::read_to_string) .transpose() .map_err(Error::Io)? .map(|v| T::generate_file_header(v.lines())); diff --git a/runtime/src/codec/bits.rs b/runtime/src/codec/bits.rs index bf0696c..5365259 100644 --- a/runtime/src/codec/bits.rs +++ b/runtime/src/codec/bits.rs @@ -230,7 +230,7 @@ impl BitCodec for BitCodecBE { value: T, ) { let mask: usize = (1 << BIT_SIZE) - 1; - let reset_mask = !(mask << 8 - (BIT_SIZE % 8) - BIT_OFFSET); + let reset_mask = !(mask << (8 - (BIT_SIZE % 8) - BIT_OFFSET)); let original = T::read_bytes_be(buffer); let clean = original & T::from_usize(reset_mask); let value = (value & T::from_usize(mask)) << T::from_usize(8 - (BIT_SIZE % 8) - BIT_OFFSET);