]> git.proxmox.com Git - rustc.git/blobdiff - src/doc/nomicon/src/vec-alloc.md
New upstream version 1.45.0+dfsg1
[rustc.git] / src / doc / nomicon / src / vec-alloc.md
index b19de4abd878015a33aeb9b6124568c20a5105e7..2bc56f3c8a1ef3331ffc53028143c2d28971631f 100644 (file)
@@ -9,8 +9,8 @@ This is perfectly fine because we already have `cap == 0` as our sentinel for no
 allocation. We don't even need to handle it specially in almost any code because
 we usually need to check if `cap > len` or `len > 0` anyway. The recommended
 Rust value to put here is `mem::align_of::<T>()`. Unique provides a convenience
-for this: `Unique::empty()`. There are quite a few places where we'll
-want to use `empty` because there's no real allocation to talk about but
+for this: `Unique::dangling()`. There are quite a few places where we'll
+want to use `dangling` because there's no real allocation to talk about but
 `null` would make the compiler do bad things.
 
 So:
@@ -23,7 +23,7 @@ use std::mem;
 impl<T> Vec<T> {
     fn new() -> Self {
         assert!(mem::size_of::<T>() != 0, "We're not ready to handle ZSTs");
-        Vec { ptr: Unique::empty(), len: 0, cap: 0 }
+        Vec { ptr: Unique::dangling(), len: 0, cap: 0 }
     }
 }
 ```