diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2018-10-23 02:04:14 +0200 |
|---|---|---|
| committer | Mazdak Farrokhzad <twingoow@gmail.com> | 2018-11-10 01:07:32 +0100 |
| commit | 5b89877dda5b8267f1ec35dfc9bb6ddc4472f006 (patch) | |
| tree | 0f5237eeb066e1d8d27ed5fbeb7fca0ccb966957 /src/libcore/slice | |
| parent | b4c046b342f01bf2e750e6ac824b94be4b72c8ec (diff) | |
| download | rust-5b89877dda5b8267f1ec35dfc9bb6ddc4472f006.tar.gz rust-5b89877dda5b8267f1ec35dfc9bb6ddc4472f006.zip | |
constify parts of libcore.
Diffstat (limited to 'src/libcore/slice')
| -rw-r--r-- | src/libcore/slice/memchr.rs | 6 | ||||
| -rw-r--r-- | src/libcore/slice/mod.rs | 7 |
2 files changed, 6 insertions, 7 deletions
diff --git a/src/libcore/slice/memchr.rs b/src/libcore/slice/memchr.rs index cf95333af9c..deaeb53e84a 100644 --- a/src/libcore/slice/memchr.rs +++ b/src/libcore/slice/memchr.rs @@ -29,19 +29,19 @@ const HI_USIZE: usize = HI_U64 as usize; /// bytes where the borrow propagated all the way to the most significant /// bit." #[inline] -fn contains_zero_byte(x: usize) -> bool { +const fn contains_zero_byte(x: usize) -> bool { x.wrapping_sub(LO_USIZE) & !x & HI_USIZE != 0 } #[cfg(target_pointer_width = "16")] #[inline] -fn repeat_byte(b: u8) -> usize { +const fn repeat_byte(b: u8) -> usize { (b as usize) << 8 | b as usize } #[cfg(not(target_pointer_width = "16"))] #[inline] -fn repeat_byte(b: u8) -> usize { +const fn repeat_byte(b: u8) -> usize { (b as usize) * (::usize::MAX / 255) } diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index 8a6b212020b..f8dee537062 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -385,7 +385,6 @@ impl<T> [T] { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] - #[rustc_const_unstable(feature = "const_slice_as_ptr")] pub const fn as_ptr(&self) -> *const T { self as *const [T] as *const T } @@ -2738,7 +2737,7 @@ impl<'a, T> IntoIterator for &'a mut [T] { // Macro helper functions #[inline(always)] -fn size_from_ptr<T>(_: *const T) -> usize { +const fn size_from_ptr<T>(_: *const T) -> usize { mem::size_of::<T>() } @@ -4022,7 +4021,7 @@ impl<'a, T> ChunksExact<'a, T> { /// returned by the iterator. The returned slice has at most `chunk_size-1` /// elements. #[stable(feature = "chunks_exact", since = "1.31.0")] - pub fn remainder(&self) -> &'a [T] { + pub const fn remainder(&self) -> &'a [T] { self.rem } } @@ -4518,7 +4517,7 @@ impl<'a, T> RChunksExact<'a, T> { /// returned by the iterator. The returned slice has at most `chunk_size-1` /// elements. #[stable(feature = "rchunks", since = "1.31.0")] - pub fn remainder(&self) -> &'a [T] { + pub const fn remainder(&self) -> &'a [T] { self.rem } } |
