@@ -123,6 +123,7 @@ use std::io::{Result, Write};
123
123
pub struct OwnedBuf {
124
124
data : * mut MaybeUninit < u8 > ,
125
125
dtor : unsafe fn ( & mut OwnedBuf ) ,
126
+ user_data : * const ( ) ,
126
127
capacity : usize ,
127
128
/// The length of `self.data` which is known to be filled.
128
129
filled : usize ,
@@ -152,13 +153,15 @@ impl OwnedBuf {
152
153
pub unsafe fn new (
153
154
data : * mut MaybeUninit < u8 > ,
154
155
dtor : unsafe fn ( & mut OwnedBuf ) ,
156
+ user_data : * const ( ) ,
155
157
capacity : usize ,
156
158
filled : usize ,
157
159
init : usize ,
158
160
) -> OwnedBuf {
159
161
OwnedBuf {
160
162
data,
161
163
dtor,
164
+ user_data,
162
165
capacity,
163
166
filled,
164
167
init,
@@ -172,7 +175,7 @@ impl OwnedBuf {
172
175
/// It is only safe to use this method if the buffer was created from a `Vec<u8>`.
173
176
#[ inline]
174
177
pub unsafe fn into_vec ( self ) -> Vec < u8 > {
175
- let ( data, _, filled, _, capacity) = self . into_raw_parts ( ) ;
178
+ let ( data, _, _ , filled, _, capacity) = self . into_raw_parts ( ) ;
176
179
Vec :: from_raw_parts ( data as * mut u8 , filled, capacity)
177
180
}
178
181
@@ -183,7 +186,7 @@ impl OwnedBuf {
183
186
/// It is only safe to use this method if the buffer was created from a `Vec<MaybeUninit<u8>>`.
184
187
#[ inline]
185
188
pub unsafe fn into_maybe_uninit_vec ( self ) -> Vec < MaybeUninit < u8 > > {
186
- let ( data, _, filled, _, capacity) = self . into_raw_parts ( ) ;
189
+ let ( data, _, _ , filled, _, capacity) = self . into_raw_parts ( ) ;
187
190
Vec :: from_raw_parts ( data, filled, capacity)
188
191
}
189
192
@@ -299,12 +302,20 @@ impl OwnedBuf {
299
302
) -> (
300
303
* mut MaybeUninit < u8 > ,
301
304
unsafe fn ( & mut OwnedBuf ) ,
305
+ * const ( ) ,
302
306
usize ,
303
307
usize ,
304
308
usize ,
305
309
) {
306
310
let this = ManuallyDrop :: new ( self ) ;
307
- ( this. data , this. dtor , this. filled , this. init , this. capacity )
311
+ (
312
+ this. data ,
313
+ this. dtor ,
314
+ this. user_data ,
315
+ this. filled ,
316
+ this. init ,
317
+ this. capacity ,
318
+ )
308
319
}
309
320
}
310
321
@@ -315,7 +326,7 @@ impl Drop for OwnedBuf {
315
326
}
316
327
317
328
unsafe fn drop_vec ( buf : & mut OwnedBuf ) {
318
- let ( data, _, filled, _, capacity) = unsafe { ptr:: read ( buf) } . into_raw_parts ( ) ;
329
+ let ( data, _, _ , filled, _, capacity) = unsafe { ptr:: read ( buf) } . into_raw_parts ( ) ;
319
330
let _vec = Vec :: from_raw_parts ( data, filled, capacity) ;
320
331
}
321
332
@@ -325,6 +336,7 @@ impl From<Vec<MaybeUninit<u8>>> for OwnedBuf {
325
336
OwnedBuf {
326
337
data,
327
338
dtor : drop_vec,
339
+ user_data : ptr:: null ( ) ,
328
340
capacity,
329
341
filled : len,
330
342
init : len,
@@ -338,6 +350,7 @@ impl From<Vec<u8>> for OwnedBuf {
338
350
OwnedBuf {
339
351
data : data as * mut MaybeUninit < u8 > ,
340
352
dtor : drop_vec,
353
+ user_data : ptr:: null ( ) ,
341
354
capacity,
342
355
filled : len,
343
356
init : len,
0 commit comments