Fix Bytes::is_unique when created from shared BytesMut (#718)

The `is_unique` entry in the vtable for `Bytes` created from a shared
`BytesMut` just called the `shared_is_unique` function from the `bytes`
module. However, that function dereferences the `data` argument` as
`bytes::Shared`, but the actual underlying type is `bytes_mut::Shared`.
This commit is contained in:
Emily Crandall Fleischman
2024-07-13 01:09:46 +02:00
committed by GitHub
parent ce8d8a0a02
commit 6b4b0eda29
2 changed files with 16 additions and 1 deletions
+9
View File
@@ -1172,3 +1172,12 @@ fn shared_is_unique() {
drop(b);
assert!(c.is_unique());
}
#[test]
fn mut_shared_is_unique() {
let mut b = BytesMut::from(LONG);
let c = b.split().freeze();
assert!(!c.is_unique());
drop(b);
assert!(c.is_unique());
}