Skip to content

Commit

Permalink
Derive Default, Eq and PartialEq for the reports (#66)
Browse files Browse the repository at this point in the history
There was already a default implementation for KeyboardReport but it can
be derived as well.

Also derive Eq & PartialEq to be able to know if 2 reports are different.
  • Loading branch information
borisfaure authored Jul 16, 2024
1 parent 663be09 commit 76325c3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 12 deletions.
2 changes: 1 addition & 1 deletion macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ pub fn gen_hid_descriptor(args: TokenStream, input: TokenStream) -> TokenStream
let (descriptor, fields) = output;

let mut out = quote! {
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, Default, Eq, PartialEq)]
#[repr(C, packed)]
#decl

Expand Down
11 changes: 0 additions & 11 deletions src/descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,6 @@ pub struct KeyboardReport {
pub keycodes: [u8; 6],
}

impl KeyboardReport {
pub const fn default() -> Self {
Self {
modifier: 0,
reserved: 0,
leds: 0,
keycodes: [0u8; 6],
}
}
}

/// KeyboardUsage describes the key codes to be used in implementing a USB keyboard.
///
/// The usage type of all key codes is Selectors, except for the modifier keys
Expand Down

0 comments on commit 76325c3

Please sign in to comment.