Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup. Remove unnecessary self.clone() calls #213

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading