@@ -225,7 +225,7 @@ pub struct AssertParamIsCopy<T: Copy + ?Sized> {
225
225
/// # Safety
226
226
///
227
227
/// Implementations must ensure that when `.clone_to_uninit()` returns normally rather than
228
- /// panicking, it always leaves `*dst ` initialized as a valid value of type `Self`.
228
+ /// panicking, it always leaves `*dest ` initialized as a valid value of type `Self`.
229
229
///
230
230
/// # Examples
231
231
///
@@ -280,7 +280,7 @@ pub struct AssertParamIsCopy<T: Copy + ?Sized> {
280
280
/// }
281
281
///
282
282
/// unsafe impl<T: ?Sized + CloneToUninit> CloneToUninit for MyDst<T> {
283
- /// unsafe fn clone_to_uninit(&self, dst : *mut u8) {
283
+ /// unsafe fn clone_to_uninit(&self, dest : *mut u8) {
284
284
/// let offset_of_flag = offset_of!(Self, flag);
285
285
/// // The offset of `self.contents` is dynamic because it depends on the alignment of T
286
286
/// // which can be dynamic (if `T = dyn SomeTrait`). Therefore, we have to obtain it
@@ -293,13 +293,13 @@ pub struct AssertParamIsCopy<T: Copy + ?Sized> {
293
293
/// // Since `flag` implements `Copy`, we can just copy it.
294
294
/// // We use `pointer::write()` instead of assignment because the destination may be
295
295
/// // uninitialized.
296
- /// dst .add(offset_of_flag).cast::<bool>().write(self.flag);
296
+ /// dest .add(offset_of_flag).cast::<bool>().write(self.flag);
297
297
///
298
298
/// // Note: if `flag` owned any resources (i.e. had a `Drop` implementation), then we
299
299
/// // must prepare to drop it in case `self.contents.clone_to_uninit()` panics.
300
300
/// // In this simple case, where we have exactly one field for which `mem::needs_drop()`
301
301
/// // might be true (`contents`), we don’t need to care about cleanup or ordering.
302
- /// self.contents.clone_to_uninit(dst .add(offset_of_contents));
302
+ /// self.contents.clone_to_uninit(dest .add(offset_of_contents));
303
303
///
304
304
/// // All fields of the struct have been initialized, therefore the struct is initialized,
305
305
/// // and we have satisfied our `unsafe impl CloneToUninit` obligations.
@@ -337,22 +337,22 @@ pub struct AssertParamIsCopy<T: Copy + ?Sized> {
337
337
/// [trait object]: https://doc.rust-lang.org/reference/types/trait-object.html
338
338
#[ unstable( feature = "clone_to_uninit" , issue = "126799" ) ]
339
339
pub unsafe trait CloneToUninit {
340
- /// Performs copy-assignment from `self` to `dst `.
340
+ /// Performs copy-assignment from `self` to `dest `.
341
341
///
342
- /// This is analogous to `std::ptr::write(dst .cast(), self.clone())`,
342
+ /// This is analogous to `std::ptr::write(dest .cast(), self.clone())`,
343
343
/// except that `Self` may be a dynamically-sized type ([`!Sized`](Sized)).
344
344
///
345
- /// Before this function is called, `dst ` may point to uninitialized memory.
346
- /// After this function is called, `dst ` will point to initialized memory; it will be
345
+ /// Before this function is called, `dest ` may point to uninitialized memory.
346
+ /// After this function is called, `dest ` will point to initialized memory; it will be
347
347
/// sound to create a `&Self` reference from the pointer with the [pointer metadata]
348
348
/// from `self`.
349
349
///
350
350
/// # Safety
351
351
///
352
352
/// Behavior is undefined if any of the following conditions are violated:
353
353
///
354
- /// * `dst ` must be [valid] for writes for `std::mem::size_of_val(self)` bytes.
355
- /// * `dst ` must be properly aligned to `std::mem::align_of_val(self)`.
354
+ /// * `dest ` must be [valid] for writes for `std::mem::size_of_val(self)` bytes.
355
+ /// * `dest ` must be properly aligned to `std::mem::align_of_val(self)`.
356
356
///
357
357
/// [valid]: crate::ptr#safety
358
358
/// [pointer metadata]: crate::ptr::metadata()
@@ -361,60 +361,60 @@ pub unsafe trait CloneToUninit {
361
361
///
362
362
/// This function may panic. (For example, it might panic if memory allocation for a clone
363
363
/// of a value owned by `self` fails.)
364
- /// If the call panics, then `*dst ` should be treated as uninitialized memory; it must not be
364
+ /// If the call panics, then `*dest ` should be treated as uninitialized memory; it must not be
365
365
/// read or dropped, because even if it was previously valid, it may have been partially
366
366
/// overwritten.
367
367
///
368
- /// The caller may also need to take care to deallocate the allocation pointed to by `dst `,
368
+ /// The caller may also need to take care to deallocate the allocation pointed to by `dest `,
369
369
/// if applicable, to avoid a memory leak, and may need to take other precautions to ensure
370
370
/// soundness in the presence of unwinding.
371
371
///
372
372
/// Implementors should avoid leaking values by, upon unwinding, dropping all component values
373
373
/// that might have already been created. (For example, if a `[Foo]` of length 3 is being
374
374
/// cloned, and the second of the three calls to `Foo::clone()` unwinds, then the first `Foo`
375
375
/// cloned should be dropped.)
376
- unsafe fn clone_to_uninit ( & self , dst : * mut u8 ) ;
376
+ unsafe fn clone_to_uninit ( & self , dest : * mut u8 ) ;
377
377
}
378
378
379
379
#[ unstable( feature = "clone_to_uninit" , issue = "126799" ) ]
380
380
unsafe impl < T : Clone > CloneToUninit for T {
381
381
#[ inline]
382
- unsafe fn clone_to_uninit ( & self , dst : * mut u8 ) {
382
+ unsafe fn clone_to_uninit ( & self , dest : * mut u8 ) {
383
383
// SAFETY: we're calling a specialization with the same contract
384
- unsafe { <T as self :: uninit:: CopySpec >:: clone_one ( self , dst . cast :: < T > ( ) ) }
384
+ unsafe { <T as self :: uninit:: CopySpec >:: clone_one ( self , dest . cast :: < T > ( ) ) }
385
385
}
386
386
}
387
387
388
388
#[ unstable( feature = "clone_to_uninit" , issue = "126799" ) ]
389
389
unsafe impl < T : Clone > CloneToUninit for [ T ] {
390
390
#[ inline]
391
391
#[ cfg_attr( debug_assertions, track_caller) ]
392
- unsafe fn clone_to_uninit ( & self , dst : * mut u8 ) {
393
- let dst : * mut [ T ] = dst . with_metadata_of ( self ) ;
392
+ unsafe fn clone_to_uninit ( & self , dest : * mut u8 ) {
393
+ let dest : * mut [ T ] = dest . with_metadata_of ( self ) ;
394
394
// SAFETY: we're calling a specialization with the same contract
395
- unsafe { <T as self :: uninit:: CopySpec >:: clone_slice ( self , dst ) }
395
+ unsafe { <T as self :: uninit:: CopySpec >:: clone_slice ( self , dest ) }
396
396
}
397
397
}
398
398
399
399
#[ unstable( feature = "clone_to_uninit" , issue = "126799" ) ]
400
400
unsafe impl CloneToUninit for str {
401
401
#[ inline]
402
402
#[ cfg_attr( debug_assertions, track_caller) ]
403
- unsafe fn clone_to_uninit ( & self , dst : * mut u8 ) {
403
+ unsafe fn clone_to_uninit ( & self , dest : * mut u8 ) {
404
404
// SAFETY: str is just a [u8] with UTF-8 invariant
405
- unsafe { self . as_bytes ( ) . clone_to_uninit ( dst ) }
405
+ unsafe { self . as_bytes ( ) . clone_to_uninit ( dest ) }
406
406
}
407
407
}
408
408
409
409
#[ unstable( feature = "clone_to_uninit" , issue = "126799" ) ]
410
410
unsafe impl CloneToUninit for crate :: ffi:: CStr {
411
411
#[ cfg_attr( debug_assertions, track_caller) ]
412
- unsafe fn clone_to_uninit ( & self , dst : * mut u8 ) {
412
+ unsafe fn clone_to_uninit ( & self , dest : * mut u8 ) {
413
413
// SAFETY: For now, CStr is just a #[repr(trasnsparent)] [c_char] with some invariants.
414
414
// And we can cast [c_char] to [u8] on all supported platforms (see: to_bytes_with_nul).
415
415
// The pointer metadata properly preserves the length (so NUL is also copied).
416
416
// See: `cstr_metadata_is_length_with_nul` in tests.
417
- unsafe { self . to_bytes_with_nul ( ) . clone_to_uninit ( dst ) }
417
+ unsafe { self . to_bytes_with_nul ( ) . clone_to_uninit ( dest ) }
418
418
}
419
419
}
420
420
0 commit comments