Skip to content

Commit

Permalink
Remove unnecessary use of vec macro
Browse files Browse the repository at this point in the history
Clippy emits:

 error: useless use of `vec!`

As suggested, remove the macro call. Rename the variable to `bytes`
instead of `v` to better suit the new array type.
  • Loading branch information
tcharding committed Oct 25, 2023
1 parent a640e7f commit cce5574
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,39 +207,39 @@ mod tests {
#[test]
fn decode_iter_forward() {
let hex = "deadbeef";
let v = vec![0xde, 0xad, 0xbe, 0xef];
let bytes = [0xde, 0xad, 0xbe, 0xef];

for (i, b) in HexToBytesIter::new(hex).unwrap().enumerate() {
assert_eq!(b.unwrap(), v[i]);
assert_eq!(b.unwrap(), bytes[i]);
}
}

#[test]
fn decode_iter_backward() {
let hex = "deadbeef";
let v = vec![0xef, 0xbe, 0xad, 0xde];
let bytes = [0xef, 0xbe, 0xad, 0xde];

for (i, b) in HexToBytesIter::new(hex).unwrap().rev().enumerate() {
assert_eq!(b.unwrap(), v[i]);
assert_eq!(b.unwrap(), bytes[i]);
}
}

#[test]
fn encode_iter() {
let v = vec![0xde, 0xad, 0xbe, 0xef];
let bytes = [0xde, 0xad, 0xbe, 0xef];
let hex = "deadbeef";

for (i, c) in BytesToHexIter::new(v.iter().cloned()).enumerate() {
for (i, c) in BytesToHexIter::new(bytes.iter().cloned()).enumerate() {
assert_eq!(c, hex.chars().nth(i).unwrap());
}
}

#[test]
fn encode_iter_backwards() {
let v = vec![0xde, 0xad, 0xbe, 0xef];
let bytes = [0xde, 0xad, 0xbe, 0xef];
let hex = "efbeadde";

for (i, c) in BytesToHexIter::new(v.iter().cloned()).rev().enumerate() {
for (i, c) in BytesToHexIter::new(bytes.iter().cloned()).rev().enumerate() {
assert_eq!(c, hex.chars().nth(i).unwrap());
}
}
Expand Down

0 comments on commit cce5574

Please sign in to comment.