mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-08-20 00:00:10 +02:00
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:
@@ -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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user