Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
improve chunks + windows err on size 0
  • Loading branch information
lcnr committed Jul 30, 2020
1 parent 1799d31 commit 870b7cb
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions library/core/src/slice/mod.rs
Expand Up @@ -680,7 +680,7 @@ impl<T> [T] {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn windows(&self, size: usize) -> Windows<'_, T> {
assert!(size != 0);
assert_ne!(size, 0);
Windows { v: self, size }
}

Expand Down Expand Up @@ -714,7 +714,7 @@ impl<T> [T] {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn chunks(&self, chunk_size: usize) -> Chunks<'_, T> {
assert!(chunk_size != 0);
assert_ne!(chunk_size, 0);
Chunks { v: self, chunk_size }
}

Expand Down Expand Up @@ -752,7 +752,7 @@ impl<T> [T] {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn chunks_mut(&mut self, chunk_size: usize) -> ChunksMut<'_, T> {
assert!(chunk_size != 0);
assert_ne!(chunk_size, 0);
ChunksMut { v: self, chunk_size }
}

Expand Down Expand Up @@ -789,7 +789,7 @@ impl<T> [T] {
#[stable(feature = "chunks_exact", since = "1.31.0")]
#[inline]
pub fn chunks_exact(&self, chunk_size: usize) -> ChunksExact<'_, T> {
assert!(chunk_size != 0);
assert_ne!(chunk_size, 0);
let rem = self.len() % chunk_size;
let len = self.len() - rem;
let (fst, snd) = self.split_at(len);
Expand Down Expand Up @@ -834,7 +834,7 @@ impl<T> [T] {
#[stable(feature = "chunks_exact", since = "1.31.0")]
#[inline]
pub fn chunks_exact_mut(&mut self, chunk_size: usize) -> ChunksExactMut<'_, T> {
assert!(chunk_size != 0);
assert_ne!(chunk_size, 0);
let rem = self.len() % chunk_size;
let len = self.len() - rem;
let (fst, snd) = self.split_at_mut(len);
Expand Down

0 comments on commit 870b7cb

Please sign in to comment.