From d2e802b827d5020c89e1d3290fe13602386a4b33 Mon Sep 17 00:00:00 2001 From: Alexis Beingessner Date: Fri, 26 Jun 2015 09:29:42 -0700 Subject: [PATCH] tweak usize::MAX --- vec.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vec.md b/vec.md index e45782c45ce..2b4e35e7653 100644 --- a/vec.md +++ b/vec.md @@ -863,8 +863,8 @@ method of RawVec. impl RawVec { fn new() -> Self { unsafe { - // -1 is usize::MAX. This branch should be stripped at compile time. - let cap = if mem::size_of::() == 0 { -1 } else { 0 }; + // !0 is usize::MAX. This branch should be stripped at compile time. + let cap = if mem::size_of::() == 0 { !0 } else { 0 }; // heap::EMPTY doubles as "unallocated" and "zero-sized allocation" RawVec { ptr: Unique::new(heap::EMPTY as *mut T), cap: cap } @@ -1036,8 +1036,8 @@ struct RawVec { impl RawVec { fn new() -> Self { unsafe { - // -1 is usize::MAX. This branch should be stripped at compile time. - let cap = if mem::size_of::() == 0 { -1 } else { 0 }; + // !0 is usize::MAX. This branch should be stripped at compile time. + let cap = if mem::size_of::() == 0 { !0 } else { 0 }; // heap::EMPTY doubles as "unallocated" and "zero-sized allocation" RawVec { ptr: Unique::new(heap::EMPTY as *mut T), cap: cap }