X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=src%2Fdoc%2Fnomicon%2Fsrc%2Fvec-alloc.md;h=2bc56f3c8a1ef3331ffc53028143c2d28971631f;hb=f9f354fc89474a056b6c177aab976167a2d807c8;hp=b19de4abd878015a33aeb9b6124568c20a5105e7;hpb=ba9703b0c9bd49a22c467ce81f2d365b162d1b9a;p=rustc.git diff --git a/src/doc/nomicon/src/vec-alloc.md b/src/doc/nomicon/src/vec-alloc.md index b19de4abd8..2bc56f3c8a 100644 --- a/src/doc/nomicon/src/vec-alloc.md +++ b/src/doc/nomicon/src/vec-alloc.md @@ -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::()`. 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 Vec { fn new() -> Self { assert!(mem::size_of::() != 0, "We're not ready to handle ZSTs"); - Vec { ptr: Unique::empty(), len: 0, cap: 0 } + Vec { ptr: Unique::dangling(), len: 0, cap: 0 } } } ```