From 9b8f8d9e961aee2beba9f27a8b8df7a547e5851c Mon Sep 17 00:00:00 2001 From: GrayJack Date: Fri, 15 Nov 2019 22:42:23 -0300 Subject: [PATCH 1/2] Make Vec::len() a const fn --- src/liballoc/vec.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 4363314dc4580..34e8ab6169ec6 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -1311,7 +1311,7 @@ impl Vec { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - pub fn len(&self) -> usize { + pub const fn len(&self) -> usize { self.len } From 88cd4fc674b93f15ea54aff159eba1a869f92f5e Mon Sep 17 00:00:00 2001 From: GrayJack Date: Fri, 15 Nov 2019 22:44:59 -0300 Subject: [PATCH 2/2] Make Vec::is_empty() a const fn --- src/liballoc/vec.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 34e8ab6169ec6..78b9cac625772 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -1327,7 +1327,7 @@ impl Vec { /// assert!(!v.is_empty()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn is_empty(&self) -> bool { + pub const fn is_empty(&self) -> bool { self.len() == 0 }