From d9c0cd6f1055d65175f96a8b73aaacc805d9e083 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Mon, 27 Feb 2023 03:36:33 +0100 Subject: [PATCH] Add `has_capacity` as a proxy for `is_singleton` --- src/lib.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index ea24aed..4ba40a7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -664,6 +664,11 @@ impl ThinVec { self.header().cap() } + /// Returns `true` if the vector has the capacity to hold any element. + pub fn has_capacity(&self) -> bool { + !self.is_singleton() + } + /// Forces the length of the vector to `new_len`. /// /// This is a low-level operation that maintains none of the normal