about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2018-10-23 02:04:31 +0200
committerMazdak Farrokhzad <twingoow@gmail.com>2018-11-10 01:07:32 +0100
commit061d345c1657a86a9d94e90f916a0be8c966d062 (patch)
treedfc9d4aca8f75be75af84c9adb5bddfb6ecf8fbe
parent5b89877dda5b8267f1ec35dfc9bb6ddc4472f006 (diff)
downloadrust-061d345c1657a86a9d94e90f916a0be8c966d062.tar.gz
rust-061d345c1657a86a9d94e90f916a0be8c966d062.zip
constify parts of liballoc.
-rw-r--r--src/liballoc/collections/binary_heap.rs2
-rw-r--r--src/liballoc/collections/btree/map.rs4
-rw-r--r--src/liballoc/collections/btree/node.rs2
-rw-r--r--src/liballoc/collections/btree/set.rs4
-rw-r--r--src/liballoc/collections/linked_list.rs12
-rw-r--r--src/liballoc/collections/vec_deque.rs4
-rw-r--r--src/liballoc/raw_vec.rs4
-rw-r--r--src/liballoc/string.rs6
-rw-r--r--src/liballoc/vec.rs4
9 files changed, 21 insertions, 21 deletions
diff --git a/src/liballoc/collections/binary_heap.rs b/src/liballoc/collections/binary_heap.rs
index fcadcb544c4..e7e741dea4c 100644
--- a/src/liballoc/collections/binary_heap.rs
+++ b/src/liballoc/collections/binary_heap.rs
@@ -884,7 +884,7 @@ impl<'a, T> Hole<'a, T> {
     }
 
     #[inline]
-    fn pos(&self) -> usize {
+    const fn pos(&self) -> usize {
         self.pos
     }
 
diff --git a/src/liballoc/collections/btree/map.rs b/src/liballoc/collections/btree/map.rs
index 24c8fd3a969..8a721a50b46 100644
--- a/src/liballoc/collections/btree/map.rs
+++ b/src/liballoc/collections/btree/map.rs
@@ -2074,7 +2074,7 @@ impl<K, V> BTreeMap<K, V> {
     /// assert_eq!(a.len(), 1);
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
-    pub fn len(&self) -> usize {
+    pub const fn len(&self) -> usize {
         self.length
     }
 
@@ -2093,7 +2093,7 @@ impl<K, V> BTreeMap<K, V> {
     /// assert!(!a.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
     }
 }
diff --git a/src/liballoc/collections/btree/node.rs b/src/liballoc/collections/btree/node.rs
index deca9591fbd..10665b8e463 100644
--- a/src/liballoc/collections/btree/node.rs
+++ b/src/liballoc/collections/btree/node.rs
@@ -357,7 +357,7 @@ impl<BorrowType, K, V, Type> NodeRef<BorrowType, K, V, Type> {
 
     /// Returns the height of this node in the whole tree. Zero height denotes the
     /// leaf level.
-    pub fn height(&self) -> usize {
+    pub const fn height(&self) -> usize {
         self.height
     }
 
diff --git a/src/liballoc/collections/btree/set.rs b/src/liballoc/collections/btree/set.rs
index af9a7074e4a..6a0ecfd3f58 100644
--- a/src/liballoc/collections/btree/set.rs
+++ b/src/liballoc/collections/btree/set.rs
@@ -730,7 +730,7 @@ impl<T> BTreeSet<T> {
     /// assert_eq!(v.len(), 1);
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
-    pub fn len(&self) -> usize {
+    pub const fn len(&self) -> usize {
         self.map.len()
     }
 
@@ -747,7 +747,7 @@ impl<T> BTreeSet<T> {
     /// 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
     }
 }
diff --git a/src/liballoc/collections/linked_list.rs b/src/liballoc/collections/linked_list.rs
index 2ef84dbade0..9b2975b81a3 100644
--- a/src/liballoc/collections/linked_list.rs
+++ b/src/liballoc/collections/linked_list.rs
@@ -135,7 +135,7 @@ impl<T: fmt::Debug> fmt::Debug for IntoIter<T> {
 }
 
 impl<T> Node<T> {
-    fn new(element: T) -> Self {
+    const fn new(element: T) -> Self {
         Node {
             next: None,
             prev: None,
@@ -264,7 +264,7 @@ impl<T> LinkedList<T> {
     /// ```
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
-    pub fn new() -> Self {
+    pub const fn new() -> Self {
         LinkedList {
             head: None,
             tail: None,
@@ -341,7 +341,7 @@ impl<T> LinkedList<T> {
     /// ```
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
-    pub fn iter(&self) -> Iter<T> {
+    pub const fn iter(&self) -> Iter<T> {
         Iter {
             head: self.head,
             tail: self.tail,
@@ -401,8 +401,8 @@ impl<T> LinkedList<T> {
     /// ```
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
-    pub fn is_empty(&self) -> bool {
-        self.head.is_none()
+    pub const fn is_empty(&self) -> bool {
+        self.len() == 0
     }
 
     /// Returns the length of the `LinkedList`.
@@ -427,7 +427,7 @@ impl<T> LinkedList<T> {
     /// ```
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
-    pub fn len(&self) -> usize {
+    pub const fn len(&self) -> usize {
         self.len
     }
 
diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs
index 88e76033f27..b139b440fe1 100644
--- a/src/liballoc/collections/vec_deque.rs
+++ b/src/liballoc/collections/vec_deque.rs
@@ -933,7 +933,7 @@ impl<T> VecDeque<T> {
     /// 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.tail == self.head
     }
 
@@ -1275,7 +1275,7 @@ impl<T> VecDeque<T> {
     }
 
     #[inline]
-    fn is_contiguous(&self) -> bool {
+    const fn is_contiguous(&self) -> bool {
         self.tail <= self.head
     }
 
diff --git a/src/liballoc/raw_vec.rs b/src/liballoc/raw_vec.rs
index 837770feece..0b6f400a403 100644
--- a/src/liballoc/raw_vec.rs
+++ b/src/liballoc/raw_vec.rs
@@ -204,7 +204,7 @@ impl<T, A: Alloc> RawVec<T, A> {
     /// Gets a raw pointer to the start of the allocation. Note that this is
     /// Unique::empty() if `cap = 0` or T is zero-sized. In the former case, you must
     /// be careful.
-    pub fn ptr(&self) -> *mut T {
+    pub const fn ptr(&self) -> *mut T {
         self.ptr.as_ptr()
     }
 
@@ -221,7 +221,7 @@ impl<T, A: Alloc> RawVec<T, A> {
     }
 
     /// Returns a shared reference to the allocator backing this RawVec.
-    pub fn alloc(&self) -> &A {
+    pub const fn alloc(&self) -> &A {
         &self.a
     }
 
diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs
index 5c776292f53..8f379c4cfb4 100644
--- a/src/liballoc/string.rs
+++ b/src/liballoc/string.rs
@@ -1374,7 +1374,7 @@ impl String {
     /// ```
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
-    pub fn len(&self) -> usize {
+    pub const fn len(&self) -> usize {
         self.vec.len()
     }
 
@@ -1395,7 +1395,7 @@ impl String {
     /// ```
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
-    pub fn is_empty(&self) -> bool {
+    pub const fn is_empty(&self) -> bool {
         self.len() == 0
     }
 
@@ -1662,7 +1662,7 @@ impl FromUtf8Error {
     /// assert_eq!(1, error.valid_up_to());
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
-    pub fn utf8_error(&self) -> Utf8Error {
+    pub const fn utf8_error(&self) -> Utf8Error {
         self.error
     }
 }
diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs
index f7a0bbdceaf..78e9da2084d 100644
--- a/src/liballoc/vec.rs
+++ b/src/liballoc/vec.rs
@@ -1165,7 +1165,7 @@ impl<T> Vec<T> {
     /// ```
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
-    pub fn len(&self) -> usize {
+    pub const fn len(&self) -> usize {
         self.len
     }
 
@@ -1181,7 +1181,7 @@ impl<T> Vec<T> {
     /// 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
     }