Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 78ff333

Browse filesBrowse files
committed
Implement support for Push/Pop in "tree" parser
1 parent 1cef2ec commit 78ff333
Copy full SHA for 78ff333

File tree

Expand file treeCollapse file tree

2 files changed

+235
-124
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+235
-124
lines changed

‎usb_hid_item/src/lib.rs

Copy file name to clipboardExpand all lines: usb_hid_item/src/lib.rs
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ impl<'a> Item<'a> {
123123
.map_err(|_| UnexpectedData)
124124
.map(u8::from_le_bytes)
125125
};
126+
let d8u = || {
127+
Ok(match d {
128+
&[] => 0,
129+
&[a] => a,
130+
_ => return Err(UnexpectedData),
131+
})
132+
};
126133
let d16u = || {
127134
Ok(u16::from_le_bytes(match d {
128135
&[] => [0, 0],
@@ -156,7 +163,7 @@ impl<'a> Item<'a> {
156163
let item = match tag {
157164
Self::INPUT => Self::Input(MainFlags(d32u()?)),
158165
Self::OUTPUT => Self::Output(MainFlags(d32u()?)),
159-
Self::COLLECTION => Self::Collection(Collection::from_raw(d8()?)),
166+
Self::COLLECTION => Self::Collection(Collection::from_raw(d8u()?)),
160167
Self::FEATURE => Self::Feature(MainFlags(d32u()?)),
161168
Self::END_COLLECTION => d_empty(Self::EndCollection)?,
162169

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.