mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-08-26 00:00:20 +02:00
Bytes: only the vec repr is not shared (#100)
The shared debug_assert is to ensure that the internal Bytes representation is such that offset views are supported. The only representation that does not support offset views is vec. Fixes #97
This commit is contained in:
+2
-2
@@ -1890,8 +1890,8 @@ impl Inner {
|
|||||||
#[inline]
|
#[inline]
|
||||||
fn is_shared(&mut self) -> bool {
|
fn is_shared(&mut self) -> bool {
|
||||||
match self.kind() {
|
match self.kind() {
|
||||||
KIND_INLINE | KIND_ARC => true,
|
KIND_VEC => false,
|
||||||
_ => false,
|
_ => true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -363,6 +363,15 @@ fn extend() {
|
|||||||
assert_eq!(*bytes, LONG[..]);
|
assert_eq!(*bytes, LONG[..]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn from_static() {
|
||||||
|
let mut a = Bytes::from_static(b"ab");
|
||||||
|
let b = a.split_off(1);
|
||||||
|
|
||||||
|
assert_eq!(a, b"a"[..]);
|
||||||
|
assert_eq!(b, b"b"[..]);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
// Only run these tests on little endian systems. CI uses qemu for testing
|
// Only run these tests on little endian systems. CI uses qemu for testing
|
||||||
// little endian... and qemu doesn't really support threading all that well.
|
// little endian... and qemu doesn't really support threading all that well.
|
||||||
|
|||||||
Reference in New Issue
Block a user