refactor: reduce Iterator methods usage
This commit is contained in:
parent
5ac1a07c6b
commit
137fcc78e5
|
@ -38,16 +38,14 @@ impl<const L: usize> UsbBus for UsbDevice<L> {
|
||||||
|
|
||||||
// If ep_aadr not provided, or current endpoint is allocated, try to find next free endpoint, otherwise return UsbError. //
|
// If ep_aadr not provided, or current endpoint is allocated, try to find next free endpoint, otherwise return UsbError. //
|
||||||
_ => {
|
_ => {
|
||||||
let index = self
|
let index = self.ep_table[1..]
|
||||||
.ep_table
|
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.skip(1)
|
|
||||||
.find(|(index, ep)| {
|
.find(|(index, ep)| {
|
||||||
!ep.is_allocated && max_packet_size <= ENDPOINTS_ALLOC_LAYOUT[*index]
|
!ep.is_allocated && max_packet_size <= ENDPOINTS_ALLOC_LAYOUT[*index]
|
||||||
})
|
})
|
||||||
.ok_or(UsbError::EndpointOverflow)?
|
.map(|(index, _)| index)
|
||||||
.0;
|
.ok_or(UsbError::EndpointOverflow)?;
|
||||||
|
|
||||||
EndpointAddress::from_parts(index, ep_dir)
|
EndpointAddress::from_parts(index, ep_dir)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue