Skip to content

Commit

Permalink
Cleanup. Remove unnecessary self.clone() calls
Browse files Browse the repository at this point in the history
  • Loading branch information
antonio-sc66 authored and patrickelectric committed Jan 3, 2024
1 parent 9353461 commit 19154d8
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions build/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ impl MavType {
/// Emit reader of a given type
pub fn rust_reader(&self, val: &TokenStream, buf: Ident) -> TokenStream {
use self::MavType::*;
match self.clone() {
match self {
Char => quote! {#val = #buf.get_u8();},
UInt8 => quote! {#val = #buf.get_u8();},
UInt16 => quote! {#val = #buf.get_u16_le();},
Expand Down Expand Up @@ -837,7 +837,7 @@ impl MavType {
/// Emit writer of a given type
pub fn rust_writer(&self, val: &TokenStream, buf: Ident) -> TokenStream {
use self::MavType::*;
match self.clone() {
match self {
UInt8MavlinkVersion => quote! {#buf.put_u8(#val);},
UInt8 => quote! {#buf.put_u8(#val);},
Char => quote! {#buf.put_u8(#val);},
Expand All @@ -864,7 +864,7 @@ impl MavType {
/// Size of a given Mavtype
fn len(&self) -> usize {
use self::MavType::*;
match self.clone() {
match self {
UInt8MavlinkVersion | UInt8 | Int8 | Char => 1,
UInt16 | Int16 => 2,
UInt32 | Int32 | Float => 4,
Expand All @@ -876,7 +876,7 @@ impl MavType {
/// Used for ordering of types
fn order_len(&self) -> usize {
use self::MavType::*;
match self.clone() {
match self {
UInt8MavlinkVersion | UInt8 | Int8 | Char => 1,
UInt16 | Int16 => 2,
UInt32 | Int32 | Float => 4,
Expand All @@ -888,7 +888,7 @@ impl MavType {
/// Used for crc calculation
pub fn primitive_type(&self) -> String {
use self::MavType::*;
match self.clone() {
match self {
UInt8MavlinkVersion => "uint8_t".into(),
UInt8 => "uint8_t".into(),
Int8 => "int8_t".into(),
Expand All @@ -909,7 +909,7 @@ impl MavType {
/// Used for generating struct fields.
pub fn rust_type(&self) -> String {
use self::MavType::*;
match self.clone() {
match self {
UInt8 | UInt8MavlinkVersion => "u8".into(),
Int8 => "i8".into(),
Char => "u8".into(),
Expand All @@ -927,7 +927,6 @@ impl MavType {

pub fn emit_default_value(&self) -> TokenStream {
use self::MavType::*;

match self {
UInt8 | UInt8MavlinkVersion => quote!(0_u8),
Int8 => quote!(0_i8),
Expand Down

0 comments on commit 19154d8

Please sign in to comment.