From 137fcc78e568ee3f241b72943ce3c9273695a0d9 Mon Sep 17 00:00:00 2001 From: doryan Date: Mon, 26 May 2025 10:24:19 +0400 Subject: [PATCH] refactor: reduce Iterator methods usage --- src/lib.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 298e76b..257a02c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -38,16 +38,14 @@ impl UsbBus for UsbDevice { // If ep_aadr not provided, or current endpoint is allocated, try to find next free endpoint, otherwise return UsbError. // _ => { - let index = self - .ep_table + let index = self.ep_table[1..] .iter() .enumerate() - .skip(1) .find(|(index, ep)| { !ep.is_allocated && max_packet_size <= ENDPOINTS_ALLOC_LAYOUT[*index] }) - .ok_or(UsbError::EndpointOverflow)? - .0; + .map(|(index, _)| index) + .ok_or(UsbError::EndpointOverflow)?; EndpointAddress::from_parts(index, ep_dir) }