constify parts of liballoc.

This commit is contained in:
Mazdak Farrokhzad 2018-10-23 02:04:31 +02:00
parent 5b89877dda
commit 061d345c16
9 changed files with 21 additions and 21 deletions

View file

@ -884,7 +884,7 @@ impl<'a, T> Hole<'a, T> {
}
#[inline]
fn pos(&self) -> usize {
const fn pos(&self) -> usize {
self.pos
}

View file

@ -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
}
}

View file

@ -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
}

View file

@ -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
}
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}
}

View file

@ -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
}