提交 061d345c 编写于 作者: M Mazdak Farrokhzad

constify parts of liballoc.

上级 5b89877d
......@@ -884,7 +884,7 @@ unsafe fn new(data: &'a mut [T], pos: usize) -> Self {
}
#[inline]
fn pos(&self) -> usize {
const fn pos(&self) -> usize {
self.pos
}
......
......@@ -2074,7 +2074,7 @@ pub fn values_mut(&mut self) -> ValuesMut<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 @@ pub fn len(&self) -> usize {
/// 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
}
}
......
......@@ -357,7 +357,7 @@ pub fn len(&self) -> usize {
/// 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
}
......
......@@ -730,7 +730,7 @@ pub fn iter(&self) -> Iter<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 @@ pub fn len(&self) -> usize {
/// 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
}
}
......
......@@ -135,7 +135,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
}
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 @@ pub fn append(&mut self, other: &mut Self) {
/// ```
#[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 @@ pub fn iter_mut(&mut self) -> IterMut<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 @@ pub fn is_empty(&self) -> bool {
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn len(&self) -> usize {
pub const fn len(&self) -> usize {
self.len
}
......
......@@ -933,7 +933,7 @@ pub fn len(&self) -> usize {
/// 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 @@ pub fn pop_back(&mut self) -> Option<T> {
}
#[inline]
fn is_contiguous(&self) -> bool {
const fn is_contiguous(&self) -> bool {
self.tail <= self.head
}
......
......@@ -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 @@ pub fn cap(&self) -> usize {
}
/// Returns a shared reference to the allocator backing this RawVec.
pub fn alloc(&self) -> &A {
pub const fn alloc(&self) -> &A {
&self.a
}
......
......@@ -1374,7 +1374,7 @@ pub unsafe fn as_mut_vec(&mut self) -> &mut Vec<u8> {
/// ```
#[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 @@ pub fn len(&self) -> usize {
/// ```
#[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 @@ pub fn into_bytes(self) -> Vec<u8> {
/// 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
}
}
......
......@@ -1165,7 +1165,7 @@ pub fn clear(&mut self) {
/// ```
#[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 @@ pub fn len(&self) -> usize {
/// 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
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册