Skip to content

Commit 609a734

Browse files
Biagio Festasdroege
authored andcommitted
glib/bytes: relax start offset constraint for from_bytes
1 parent 6e103b1 commit 609a734

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

glib/src/bytes.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ impl Bytes {
109109
Bound::Excluded(v) => v.checked_add(1).expect("Invalid start offset"),
110110
Bound::Unbounded => 0,
111111
};
112-
assert!(start_offset < len, "Start offset after valid range");
112+
assert!(start_offset <= len, "Start offset after valid range");
113113

114114
let end_offset = match range.end_bound() {
115115
Bound::Included(v) => v.checked_add(1).expect("Invalid end offset"),
@@ -338,6 +338,8 @@ mod tests {
338338
assert_eq!(b2, [1u8, 2u8].as_ref());
339339
let b2 = Bytes::from_bytes(&b1, ..);
340340
assert_eq!(b2, [1u8, 2u8, 3u8].as_ref());
341+
let b2 = Bytes::from_bytes(&b1, 3..);
342+
assert_eq!(b2, [].as_ref());
341343
}
342344

343345
#[test]

0 commit comments

Comments
 (0)