Skip to content

Commit 141cbc2

Browse files
authored
Rename Vtable::to_* -> Vtable::into_* (#776)
1 parent 19d1427 commit 141cbc2

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

src/bytes.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ pub(crate) struct Vtable {
112112
pub clone: unsafe fn(&AtomicPtr<()>, *const u8, usize) -> Bytes,
113113
/// fn(data, ptr, len)
114114
///
115-
/// takes `Bytes` to value
116-
pub to_vec: unsafe fn(&AtomicPtr<()>, *const u8, usize) -> Vec<u8>,
117-
pub to_mut: unsafe fn(&AtomicPtr<()>, *const u8, usize) -> BytesMut,
115+
/// `into_*` consumes the `Bytes`, returning the respective value.
116+
pub into_vec: unsafe fn(&AtomicPtr<()>, *const u8, usize) -> Vec<u8>,
117+
pub into_mut: unsafe fn(&AtomicPtr<()>, *const u8, usize) -> BytesMut,
118118
/// fn(data)
119119
pub is_unique: unsafe fn(&AtomicPtr<()>) -> bool,
120120
/// fn(data, ptr, len)
@@ -1045,7 +1045,7 @@ impl From<Bytes> for BytesMut {
10451045
/// ```
10461046
fn from(bytes: Bytes) -> Self {
10471047
let bytes = ManuallyDrop::new(bytes);
1048-
unsafe { (bytes.vtable.to_mut)(&bytes.data, bytes.ptr, bytes.len) }
1048+
unsafe { (bytes.vtable.into_mut)(&bytes.data, bytes.ptr, bytes.len) }
10491049
}
10501050
}
10511051

@@ -1058,7 +1058,7 @@ impl From<String> for Bytes {
10581058
impl From<Bytes> for Vec<u8> {
10591059
fn from(bytes: Bytes) -> Vec<u8> {
10601060
let bytes = ManuallyDrop::new(bytes);
1061-
unsafe { (bytes.vtable.to_vec)(&bytes.data, bytes.ptr, bytes.len) }
1061+
unsafe { (bytes.vtable.into_vec)(&bytes.data, bytes.ptr, bytes.len) }
10621062
}
10631063
}
10641064

@@ -1077,8 +1077,8 @@ impl fmt::Debug for Vtable {
10771077

10781078
const STATIC_VTABLE: Vtable = Vtable {
10791079
clone: static_clone,
1080-
to_vec: static_to_vec,
1081-
to_mut: static_to_mut,
1080+
into_vec: static_to_vec,
1081+
into_mut: static_to_mut,
10821082
is_unique: static_is_unique,
10831083
drop: static_drop,
10841084
};
@@ -1181,8 +1181,8 @@ unsafe fn owned_drop(data: &mut AtomicPtr<()>, _ptr: *const u8, _len: usize) {
11811181

11821182
static OWNED_VTABLE: Vtable = Vtable {
11831183
clone: owned_clone,
1184-
to_vec: owned_to_vec,
1185-
to_mut: owned_to_mut,
1184+
into_vec: owned_to_vec,
1185+
into_mut: owned_to_mut,
11861186
is_unique: owned_is_unique,
11871187
drop: owned_drop,
11881188
};
@@ -1191,16 +1191,16 @@ static OWNED_VTABLE: Vtable = Vtable {
11911191

11921192
static PROMOTABLE_EVEN_VTABLE: Vtable = Vtable {
11931193
clone: promotable_even_clone,
1194-
to_vec: promotable_even_to_vec,
1195-
to_mut: promotable_even_to_mut,
1194+
into_vec: promotable_even_to_vec,
1195+
into_mut: promotable_even_to_mut,
11961196
is_unique: promotable_is_unique,
11971197
drop: promotable_even_drop,
11981198
};
11991199

12001200
static PROMOTABLE_ODD_VTABLE: Vtable = Vtable {
12011201
clone: promotable_odd_clone,
1202-
to_vec: promotable_odd_to_vec,
1203-
to_mut: promotable_odd_to_mut,
1202+
into_vec: promotable_odd_to_vec,
1203+
into_mut: promotable_odd_to_mut,
12041204
is_unique: promotable_is_unique,
12051205
drop: promotable_odd_drop,
12061206
};
@@ -1375,8 +1375,8 @@ const _: [(); 0 - mem::align_of::<Shared>() % 2] = []; // Assert that the alignm
13751375

13761376
static SHARED_VTABLE: Vtable = Vtable {
13771377
clone: shared_clone,
1378-
to_vec: shared_to_vec,
1379-
to_mut: shared_to_mut,
1378+
into_vec: shared_to_vec,
1379+
into_mut: shared_to_mut,
13801380
is_unique: shared_is_unique,
13811381
drop: shared_drop,
13821382
};

src/bytes_mut.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1776,8 +1776,8 @@ unsafe fn rebuild_vec(ptr: *mut u8, mut len: usize, mut cap: usize, off: usize)
17761776

17771777
static SHARED_VTABLE: Vtable = Vtable {
17781778
clone: shared_v_clone,
1779-
to_vec: shared_v_to_vec,
1780-
to_mut: shared_v_to_mut,
1779+
into_vec: shared_v_to_vec,
1780+
into_mut: shared_v_to_mut,
17811781
is_unique: shared_v_is_unique,
17821782
drop: shared_v_drop,
17831783
};

0 commit comments

Comments
 (0)