Skip to content
This repository was archived by the owner on Dec 15, 2021. It is now read-only.

Commit ebed840

Browse files
author
Alex Helfet
committed
Use heapless::Vec::resize_default.
1 parent b76b56a commit ebed840

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,10 @@ ref_slice = "^1.1.0"
2121

2222
[dev-dependencies]
2323
tempdir = "0.3.5"
24+
25+
# Patch `heapless` with my fork until my [PR] is merged.
26+
# Adds methods Vec::resize() and Vec::resize_default()
27+
# [PR] https://github.com/japaric/heapless/pull/13
28+
[patch.crates-io.heapless]
29+
git = "https://github.com/fluffysquirrels/heapless"
30+
rev = "0917beb92a92d06f6267ee595a65cb0858f3ed59"

src/bin/itmdump.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,8 @@ fn read_packet(input: &mut Read) -> Result<Packet> {
205205
_ => return Err(Error::from(
206206
ErrorKind::UnknownHeader(header))),
207207
};
208-
// TODO: payload.resize_default(), would be nice.
209-
for _ in 0..payload_size {
210-
packet.payload.push(0)
211-
.expect("payload_size <= packet.payload.capacity");
212-
}
208+
packet.payload.resize_default(payload_size)
209+
.expect("payload_size <= packet.payload.capacity");
213210
input.read_exact(&mut *packet.payload)?;
214211
Ok(packet)
215212
},

0 commit comments

Comments
 (0)