Skip to content

Non-intuitive HexToBytesIter behavior #177

@stevenroose

Description

@stevenroose

This test passes:

fn main() {
	let good_hex = "deadbeef00deadbeef";
	let bad_hex = "deadbeefXX00XXdeadbeef";

	let mut buf = vec![];
	let mut iter = HexToBytesIter::new(good_hex).unwrap();
	iter.read_to_end(&mut buf).unwrap();
	assert_eq!(buf.as_hex().to_string(), good_hex);

	let mut buf = vec![];
	let mut iter = HexToBytesIter::new(bad_hex).unwrap();
	iter.read_to_end(&mut buf).unwrap();
	assert_eq!(buf.as_hex().to_string(), good_hex);
}

Because the io::Read impl does just silently drop pairs of non-hex characters. I think it would be more correct to return some io::Error for that case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions