diff --git a/Cargo.toml b/Cargo.toml index e07ddb384d..d591a449a2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ readme = "README.md" license = "MIT/Apache-2.0" repository = "https://github.com/mavlink/rust-mavlink" edition = "2018" -rust-version = "1.60.0" +rust-version = "1.65.0" [build-dependencies] crc-any = { version = "2.3.0", default-features = false } diff --git a/build/parser.rs b/build/parser.rs index e797e3882f..c9303e9a32 100644 --- a/build/parser.rs +++ b/build/parser.rs @@ -57,17 +57,14 @@ impl MavProfile { fn update_enums(mut self) -> Self { for msg in self.messages.values() { for field in &msg.fields { - if let Some(ref enum_name) = field.enumtype { - // it is an enum - if let Some(ref dsp) = field.display { - // it is a bitmask - if dsp == "bitmask" { - // find the corresponding enum - for enm in self.enums.values_mut() { - if enm.name == *enum_name { - // this is the right enum - enm.bitfield = Some(field.mavtype.rust_primitive_type()); - } + if let Some(enum_name) = &field.enumtype { + // it is a bitmask + if let Some("bitmask") = &field.display.as_deref() { + // find the corresponding enum + for enm in self.enums.values_mut() { + if enm.name == *enum_name { + // this is the right enum + enm.bitfield = Some(field.mavtype.rust_primitive_type()); } } } @@ -643,7 +640,7 @@ impl MavField { if matches!(self.mavtype, MavType::Array(_, _)) { let rt = TokenStream::from_str(&self.mavtype.rust_type()).unwrap(); mavtype = quote!(#rt); - } else if let Some(ref enumname) = self.enumtype { + } else if let Some(enumname) = &self.enumtype { let en = TokenStream::from_str(enumname).unwrap(); mavtype = quote!(#en); } else { @@ -1122,7 +1119,7 @@ pub fn parse_profile( let attr = attr.unwrap(); match stack.last() { Some(&MavXmlElement::Enum) => { - if let b"name" = attr.key.into_inner() { + if attr.key.into_inner() == b"name" { mavenum.name = attr .value .clone() @@ -1273,7 +1270,7 @@ pub fn parse_profile( entry.description = Some(s.replace('\n', " ")); } (Some(&Param), Some(&Entry)) => { - if let Some(ref mut params) = entry.params { + if let Some(params) = &mut entry.params { // Some messages can jump between values, like: // 0, 1, 2, 7 if params.len() < paramid.unwrap() { @@ -1452,7 +1449,7 @@ impl MavXmlFilter { } Some(kind) => kind, }; - if let MavXmlElement::Extensions = id { + if id == MavXmlElement::Extensions { self.extension_filter.is_in = true; } } @@ -1467,7 +1464,7 @@ impl MavXmlFilter { Some(kind) => kind, }; - if let MavXmlElement::Message = id { + if id == MavXmlElement::Message { self.extension_filter.is_in = false; } } diff --git a/src/connection/udp.rs b/src/connection/udp.rs index 3bcd05a6f2..7357ca99c3 100644 --- a/src/connection/udp.rs +++ b/src/connection/udp.rs @@ -74,8 +74,7 @@ struct PacketBuf { impl PacketBuf { pub fn new() -> Self { - let mut v = Vec::new(); - v.resize(65536, 0); + let v = vec![0; 65536]; Self { buf: v, start: 0,