Skip to content

Commit

Permalink
Merge pull request #123 from ithinuel/satisfy-clippy
Browse files Browse the repository at this point in the history
Add Clippy checks
  • Loading branch information
ryan-summers authored Jul 26, 2023
2 parents 98ccb7f + 19414a4 commit e31d70b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/rustfmt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ jobs:
with:
command: fmt
args: --all -- --check
- uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-features
8 changes: 4 additions & 4 deletions src/descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,9 @@ impl DescriptorWriter<'_> {
///
/// * `endpoint` - Endpoint previously allocated with
/// [`UsbBusAllocator`](crate::bus::UsbBusAllocator).
pub fn endpoint<'e, B: UsbBus, D: EndpointDirection>(
pub fn endpoint<B: UsbBus, D: EndpointDirection>(
&mut self,
endpoint: &Endpoint<'e, B, D>,
endpoint: &Endpoint<'_, B, D>,
) -> Result<()> {
self.endpoint_ex(endpoint, |_| Ok(0))
}
Expand All @@ -310,9 +310,9 @@ impl DescriptorWriter<'_> {
/// * `endpoint` - Endpoint previously allocated with
/// [`UsbBusAllocator`](crate::bus::UsbBusAllocator).
/// * `f` - Callback for the extra data. See `write_with` for more information.
pub fn endpoint_ex<'e, B: UsbBus, D: EndpointDirection>(
pub fn endpoint_ex<B: UsbBus, D: EndpointDirection>(
&mut self,
endpoint: &Endpoint<'e, B, D>,
endpoint: &Endpoint<'_, B, D>,
f: impl FnOnce(&mut [u8]) -> Result<usize>,
) -> Result<()> {
match self.num_endpoints_mark {
Expand Down
10 changes: 4 additions & 6 deletions src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,12 +366,10 @@ impl<B: UsbBus> UsbDevice<'_, B> {
// Ask class implementations, whether they know the alternate setting
// of the interface in question
for cls in classes {
match cls.get_alt_setting(InterfaceNumber(req.index as u8)) {
Some(setting) => {
xfer.accept_with(&setting.to_le_bytes()).ok();
return;
}
None => (),
if let Some(setting) = cls.get_alt_setting(InterfaceNumber(req.index as u8))
{
xfer.accept_with(&setting.to_le_bytes()).ok();
return;
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/test_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl<B: UsbBus> TestClass<'_, B> {
}

/// Convenience method to create a UsbDevice that is configured correctly for TestClass.
pub fn make_device<'a, 'b>(&'a self, usb_bus: &'b UsbBusAllocator<B>) -> UsbDevice<'b, B> {
pub fn make_device<'a>(&self, usb_bus: &'a UsbBusAllocator<B>) -> UsbDevice<'a, B> {
self.make_device_builder(usb_bus).build()
}

Expand All @@ -108,10 +108,10 @@ impl<B: UsbBus> TestClass<'_, B> {
///
/// on the returned builder. If you change the manufacturer, product, or serial number fields,
/// the test host may misbehave.
pub fn make_device_builder<'a, 'b>(
&'a self,
usb_bus: &'b UsbBusAllocator<B>,
) -> UsbDeviceBuilder<'b, B> {
pub fn make_device_builder<'a>(
&self,
usb_bus: &'a UsbBusAllocator<B>,
) -> UsbDeviceBuilder<'a, B> {
UsbDeviceBuilder::new(usb_bus, UsbVidPid(VID, PID))
.manufacturer(MANUFACTURER)
.product(PRODUCT)
Expand Down Expand Up @@ -311,7 +311,7 @@ impl<B: UsbBus> UsbClass<B> for TestClass<'_, B> {

xfer.accept().expect("control_out REQ_STORE_REQUEST failed");
}
REQ_WRITE_BUFFER if xfer.data().len() as usize <= self.control_buf.len() => {
REQ_WRITE_BUFFER if xfer.data().len() <= self.control_buf.len() => {
assert_eq!(
xfer.data().len(),
req.length as usize,
Expand Down

0 comments on commit e31d70b

Please sign in to comment.