Update to 0.5.3

epel9
Josh Stone 5 years ago
parent ce76ed2ae1
commit 0baa808def

1
.gitignore vendored

@ -2,3 +2,4 @@
/sized-chunks-0.3.2.crate /sized-chunks-0.3.2.crate
/sized-chunks-0.5.1.crate /sized-chunks-0.5.1.crate
/sized-chunks-0.5.2.crate /sized-chunks-0.5.2.crate
/sized-chunks-0.5.3.crate

@ -1,363 +0,0 @@
From c55b051afa5095b9218bcbc8f10bff3f9d2b9190 Mon Sep 17 00:00:00 2001
From: Bodil Stokke <bodil@bodil.org>
Date: Tue, 10 Mar 2020 21:14:25 +0000
Subject: [PATCH] Revert "Do consistency assertions only in debug mode."
This reverts commit 93db48b9a889160651b3e45d64bac450f32e9a66.
Closes #7.
---
CHANGELOG.md | 7 +++++++
src/inline_array/mod.rs | 8 ++++----
src/ring_buffer/mod.rs | 32 ++++++++++++++++----------------
src/sized_chunk/mod.rs | 39 ++++++++++++++++++++-------------------
src/sparse_chunk/mod.rs | 4 ++--
5 files changed, 49 insertions(+), 41 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 84cb2b629d56..1467a7c9005b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project
adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
+## [Unreleased]
+
+### FIXED
+
+- Debug only assertions made it into the previous release by accident, and this change has been
+ reverted. (#7)
+
## [0.5.2] - 2020-03-10
### ADDED
diff --git a/src/inline_array/mod.rs b/src/inline_array/mod.rs
index da62447d49ab..3325161560ed 100644
--- a/src/inline_array/mod.rs
+++ b/src/inline_array/mod.rs
@@ -177,7 +177,7 @@ impl<A, T> InlineArray<A, T> {
///
/// Time: O(1)
pub fn push(&mut self, value: A) {
- if cfg!(debug_assertions) && self.is_full() {
+ if self.is_full() {
panic!("InlineArray::push: chunk size overflow");
}
unsafe {
@@ -209,10 +209,10 @@ impl<A, T> InlineArray<A, T> {
///
/// Time: O(n) for the number of items shifted
pub fn insert(&mut self, index: usize, value: A) {
- if cfg!(debug_assertions) && self.is_full() {
+ if self.is_full() {
panic!("InlineArray::push: chunk size overflow");
}
- if cfg!(debug_assertions) && index > self.len() {
+ if index > self.len() {
panic!("InlineArray::insert: index out of bounds");
}
unsafe {
@@ -252,7 +252,7 @@ impl<A, T> InlineArray<A, T> {
///
/// Time: O(n) for the number of items in the new chunk
pub fn split_off(&mut self, index: usize) -> Self {
- if cfg!(debug_assertions) && index > self.len() {
+ if index > self.len() {
panic!("InlineArray::split_off: index out of bounds");
}
let mut out = Self::new();
diff --git a/src/ring_buffer/mod.rs b/src/ring_buffer/mod.rs
index 69de20e420f4..12690eb6feb5 100644
--- a/src/ring_buffer/mod.rs
+++ b/src/ring_buffer/mod.rs
@@ -253,7 +253,7 @@ where
I: Iterator<Item = A>,
{
let buffer = Self::from_iter(iter.take(count));
- if cfg!(debug_assertions) && buffer.len() < count {
+ if buffer.len() < count {
panic!("RingBuffer::collect_from: underfull iterator");
}
buffer
@@ -342,7 +342,7 @@ where
Bound::Excluded(index) => *index,
},
};
- if cfg!(debug_assertions) && new_range.end > self.len() || new_range.start > new_range.end {
+ if new_range.end > self.len() || new_range.start > new_range.end {
panic!("Slice::parse_range: index out of bounds");
}
new_range
@@ -428,7 +428,7 @@ where
///
/// Time: O(1)
pub fn push_back(&mut self, value: A) {
- if cfg!(debug_assertions) && self.is_full() {
+ if self.is_full() {
panic!("RingBuffer::push_back: can't push to a full buffer")
} else {
unsafe { self.force_write(self.raw(self.length), value) }
@@ -442,7 +442,7 @@ where
///
/// Time: O(1)
pub fn push_front(&mut self, value: A) {
- if cfg!(debug_assertions) && self.is_full() {
+ if self.is_full() {
panic!("RingBuffer::push_front: can't push to a full buffer")
} else {
let origin = self.origin.dec();
@@ -487,7 +487,7 @@ where
/// Time: O(n) for the number of items dropped
pub fn drop_left(&mut self, index: usize) {
if index > 0 {
- if cfg!(debug_assertions) && index > self.len() {
+ if index > self.len() {
panic!("RingBuffer::drop_left: index out of bounds");
}
for i in self.range().take(index) {
@@ -504,7 +504,7 @@ where
///
/// Time: O(n) for the number of items dropped
pub fn drop_right(&mut self, index: usize) {
- if cfg!(debug_assertions) && index > self.len() {
+ if index > self.len() {
panic!("RingBuffer::drop_right: index out of bounds");
}
if index == self.len() {
@@ -525,7 +525,7 @@ where
/// Time: O(n) for the number of items in the new buffer
#[must_use]
pub fn split_off(&mut self, index: usize) -> Self {
- if cfg!(debug_assertions) && index > self.len() {
+ if index > self.len() {
panic!("RingBuffer::split: index out of bounds");
}
if index == self.len() {
@@ -561,10 +561,10 @@ where
pub fn drain_from_front(&mut self, other: &mut Self, count: usize) {
let self_len = self.len();
let other_len = other.len();
- if cfg!(debug_assertions) && self_len + count > Self::CAPACITY {
+ if self_len + count > Self::CAPACITY {
panic!("RingBuffer::drain_from_front: chunk size overflow");
}
- if cfg!(debug_assertions) && other_len < count {
+ if other_len < count {
panic!("RingBuffer::drain_from_front: index out of bounds");
}
unsafe { self.copy_from(other, other.origin, self.raw(self.len()), count) };
@@ -583,10 +583,10 @@ where
pub fn drain_from_back(&mut self, other: &mut Self, count: usize) {
let self_len = self.len();
let other_len = other.len();
- if cfg!(debug_assertions) && self_len + count > Self::CAPACITY {
+ if self_len + count > Self::CAPACITY {
panic!("RingBuffer::drain_from_back: chunk size overflow");
}
- if cfg!(debug_assertions) && other_len < count {
+ if other_len < count {
panic!("RingBuffer::drain_from_back: index out of bounds");
}
self.origin -= count;
@@ -612,10 +612,10 @@ where
///
/// Time: O(n) for the number of items shifted
pub fn insert(&mut self, index: usize, value: A) {
- if cfg!(debug_assertions) && self.is_full() {
+ if self.is_full() {
panic!("RingBuffer::insert: chunk size overflow");
}
- if cfg!(debug_assertions) && index > self.len() {
+ if index > self.len() {
panic!("RingBuffer::insert: index out of bounds");
}
if index == 0 {
@@ -656,7 +656,7 @@ where
///
/// Time: O(n) for the number of items shifted
pub fn remove(&mut self, index: usize) -> A {
- if cfg!(debug_assertions) && index >= self.len() {
+ if index >= self.len() {
panic!("RingBuffer::remove: index out of bounds");
}
let value = unsafe { self.force_read(self.raw(index)) };
@@ -729,7 +729,7 @@ where
#[must_use]
fn index(&self, index: usize) -> &Self::Output {
- if cfg!(debug_assertions) && index >= self.len() {
+ if index >= self.len() {
panic!(
"RingBuffer::index: index out of bounds {} >= {}",
index,
@@ -746,7 +746,7 @@ where
{
#[must_use]
fn index_mut(&mut self, index: usize) -> &mut Self::Output {
- if cfg!(debug_assertions) && index >= self.len() {
+ if index >= self.len() {
panic!(
"RingBuffer::index_mut: index out of bounds {} >= {}",
index,
diff --git a/src/sized_chunk/mod.rs b/src/sized_chunk/mod.rs
index 07f6be59ad89..f9fece93d4eb 100644
--- a/src/sized_chunk/mod.rs
+++ b/src/sized_chunk/mod.rs
@@ -300,7 +300,7 @@ where
///
/// Time: O(1) if there's room at the front, O(n) otherwise
pub fn push_front(&mut self, value: A) {
- if cfg!(debug_assertions) && self.is_full() {
+ if self.is_full() {
panic!("Chunk::push_front: can't push to full chunk");
}
if self.is_empty() {
@@ -321,7 +321,7 @@ where
///
/// Time: O(1) if there's room at the back, O(n) otherwise
pub fn push_back(&mut self, value: A) {
- if cfg!(debug_assertions) && self.is_full() {
+ if self.is_full() {
panic!("Chunk::push_back: can't push to full chunk");
}
if self.is_empty() {
@@ -342,12 +342,13 @@ where
///
/// Time: O(1)
pub fn pop_front(&mut self) -> A {
- if cfg!(debug_assertions) && self.is_empty() {
+ if self.is_empty() {
panic!("Chunk::pop_front: can't pop from empty chunk");
+ } else {
+ let value = unsafe { Chunk::force_read(self.left, self) };
+ self.left += 1;
+ value
}
- let value = unsafe { Chunk::force_read(self.left, self) };
- self.left += 1;
- value
}
/// Pop an item off the back of the chunk.
@@ -356,7 +357,7 @@ where
///
/// Time: O(1)
pub fn pop_back(&mut self) -> A {
- if cfg!(debug_assertions) && self.is_empty() {
+ if self.is_empty() {
panic!("Chunk::pop_back: can't pop from empty chunk");
} else {
self.right -= 1;
@@ -396,7 +397,7 @@ where
///
/// Time: O(n) for the number of items in the new chunk
pub fn split_off(&mut self, index: usize) -> Self {
- if cfg!(debug_assertions) && index > self.len() {
+ if index > self.len() {
panic!("Chunk::split_off: index out of bounds");
}
if index == self.len() {
@@ -419,7 +420,7 @@ where
pub fn append(&mut self, other: &mut Self) {
let self_len = self.len();
let other_len = other.len();
- if cfg!(debug_assertions) && self_len + other_len > N::USIZE {
+ if self_len + other_len > N::USIZE {
panic!("Chunk::append: chunk size overflow");
}
if self.right + other_len > N::USIZE {
@@ -443,8 +444,8 @@ where
pub fn drain_from_front(&mut self, other: &mut Self, count: usize) {
let self_len = self.len();
let other_len = other.len();
- debug_assert!(self_len + count <= N::USIZE);
- debug_assert!(other_len >= count);
+ assert!(self_len + count <= N::USIZE);
+ assert!(other_len >= count);
if self.right + count > N::USIZE {
unsafe { Chunk::force_copy(self.left, 0, self_len, self) };
self.right -= self.left;
@@ -465,8 +466,8 @@ where
pub fn drain_from_back(&mut self, other: &mut Self, count: usize) {
let self_len = self.len();
let other_len = other.len();
- debug_assert!(self_len + count <= N::USIZE);
- debug_assert!(other_len >= count);
+ assert!(self_len + count <= N::USIZE);
+ assert!(other_len >= count);
if self.left < count {
unsafe { Chunk::force_copy(self.left, N::USIZE - self_len, self_len, self) };
self.left = N::USIZE - self_len;
@@ -493,10 +494,10 @@ where
///
/// Time: O(n) for the number of elements shifted
pub fn insert(&mut self, index: usize, value: A) {
- if cfg!(debug_assertions) && self.is_full() {
+ if self.is_full() {
panic!("Chunk::insert: chunk is full");
}
- if cfg!(debug_assertions) && index > self.len() {
+ if index > self.len() {
panic!("Chunk::insert: index out of bounds");
}
let real_index = index + self.left;
@@ -540,7 +541,7 @@ where
where
A: Ord,
{
- if cfg!(debug_assertions) && self.is_full() {
+ if self.is_full() {
panic!("Chunk::insert: chunk is full");
}
match self.binary_search(&value) {
@@ -565,13 +566,13 @@ where
{
let iter = iter.into_iter();
let insert_size = iter.len();
- if cfg!(debug_assertions) && self.len() + insert_size > Self::CAPACITY {
+ if self.len() + insert_size > Self::CAPACITY {
panic!(
"Chunk::insert_from: chunk cannot fit {} elements",
insert_size
);
}
- if cfg!(debug_assertions) && index > self.len() {
+ if index > self.len() {
panic!("Chunk::insert_from: index out of bounds");
}
let real_index = index + self.left;
@@ -622,7 +623,7 @@ where
///
/// Time: O(n) for the number of items shifted
pub fn remove(&mut self, index: usize) -> A {
- if cfg!(debug_assertions) && index >= self.len() {
+ if index >= self.len() {
panic!("Chunk::remove: index out of bounds");
}
let real_index = index + self.left;
diff --git a/src/sparse_chunk/mod.rs b/src/sparse_chunk/mod.rs
index 8011b04c454b..250b0d0ecdcc 100644
--- a/src/sparse_chunk/mod.rs
+++ b/src/sparse_chunk/mod.rs
@@ -162,7 +162,7 @@ where
///
/// Returns the previous value at that index, if any.
pub fn insert(&mut self, index: usize, value: A) -> Option<A> {
- if cfg!(debug_assertions) && index >= N::USIZE {
+ if index >= N::USIZE {
panic!("SparseChunk::insert: index out of bounds");
}
if self.map.set(index, true) {
@@ -177,7 +177,7 @@ where
///
/// Returns the value, or `None` if the index had no value.
pub fn remove(&mut self, index: usize) -> Option<A> {
- if cfg!(debug_assertions) && index >= N::USIZE {
+ if index >= N::USIZE {
panic!("SparseChunk::remove: index out of bounds");
}
if self.map.set(index, false) {
--
2.24.1

@ -5,7 +5,7 @@
%global crate sized-chunks %global crate sized-chunks
Name: rust-%{crate} Name: rust-%{crate}
Version: 0.5.2 Version: 0.5.3
Release: 1%{?dist} Release: 1%{?dist}
Summary: Efficient sized chunk datatypes Summary: Efficient sized chunk datatypes
@ -14,9 +14,6 @@ License: MPLv2.0
URL: https://crates.io/crates/sized-chunks URL: https://crates.io/crates/sized-chunks
Source: %{crates_source} Source: %{crates_source}
# https://github.com/bodil/sized-chunks/issues/7
Patch1: 0001-Revert-Do-consistency-assertions-only-in-debug-mode.patch
ExclusiveArch: %{rust_arches} ExclusiveArch: %{rust_arches}
%if %{__cargo_skip_build} %if %{__cargo_skip_build}
BuildArch: noarch BuildArch: noarch
@ -98,6 +95,9 @@ which use "refpool" feature of "%{crate}" crate.
%endif %endif
%changelog %changelog
* Wed Mar 11 2020 Josh Stone <jistone@redhat.com> - 0.5.3-1
- Update to 0.5.3
* Tue Mar 10 2020 Josh Stone <jistone@redhat.com> - 0.5.2-1 * Tue Mar 10 2020 Josh Stone <jistone@redhat.com> - 0.5.2-1
- Update to 0.5.2 - Update to 0.5.2

@ -1 +1 @@
SHA512 (sized-chunks-0.5.2.crate) = d1a30720624fc3b25c0bf7a6357b5b2114c762ee647dc694ce46897e4dc5cdd44774f3610d89697e802a51e4a7575a6449646020995662ca18fee7336077baa6 SHA512 (sized-chunks-0.5.3.crate) = 9ffe2b6d0510d8cad010f4e3015f605ea0d0f4e27ded1fdfd7d7080e338bf239bec30fe85ef4576160297ad287ed006097ffc12151a2cdc578d7031d1501440b

Loading…
Cancel
Save