Skip to content

Commit 546e59b

Browse files
committed
Bump some deps, fix some warnings.
Closes #189 Closes #197
1 parent 0b3a7b2 commit 546e59b

File tree

5 files changed

+37
-94
lines changed

5 files changed

+37
-94
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

88
## [Unreleased]
99

10+
#189 #197
11+
12+
#163 #150 #154 #191 #186 #179 #173 #194 #158
13+
1014
### Added
1115

1216
- `HashSet` now implements `From<Vector<A>>` and `From<&Vector<A>> where A: Clone`.

Cargo.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,21 @@ debug = []
3939
typenum = "1.12"
4040
bitmaps = "2"
4141
sized-chunks = "0.6.4"
42-
rand_core = "0.5.1"
43-
rand_xoshiro = "0.4"
44-
quickcheck = { version = "0.9", optional = true }
45-
proptest = { version = "0.10", optional = true }
42+
rand_core = "0.6"
43+
rand_xoshiro = "0.6"
44+
quickcheck = { version = "1", optional = true }
45+
proptest = { version = "1", optional = true }
4646
serde = { version = "1", optional = true }
4747
rayon = { version = "1", optional = true }
4848
refpool = { version = "0.4", optional = true }
49-
arbitrary = { version = "0.4", optional = true }
49+
arbitrary = { version = "1.1", optional = true }
5050

5151
[dev-dependencies]
52-
proptest = "0.10"
52+
proptest = "1"
5353
serde = "1"
5454
serde_json = "1"
5555
rayon = "1"
56-
rand = { version = "0.7", features = ["small_rng"] }
57-
pretty_assertions = "0.6"
56+
rand = { version = "0.8", features = ["small_rng"] }
57+
pretty_assertions = "1"
5858
metrohash = "1"
59-
proptest-derive = "0.2"
59+
proptest-derive = "0.3"

src/arbitrary.rs

Lines changed: 18 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -3,51 +3,17 @@
33
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
44

55
use std::hash::{BuildHasher, Hash};
6-
use std::iter;
76

87
use ::arbitrary::{size_hint, Arbitrary, Result, Unstructured};
98

109
use crate::{HashMap, HashSet, OrdMap, OrdSet, Vector};
1110

12-
fn empty<T: 'static>() -> Box<dyn Iterator<Item = T>> {
13-
Box::new(iter::empty())
14-
}
15-
16-
fn shrink_collection<T: Clone, A: Clone + Arbitrary>(
17-
entries: impl Iterator<Item = T>,
18-
f: impl Fn(&T) -> Box<dyn Iterator<Item = A>>,
19-
) -> Box<dyn Iterator<Item = Vec<A>>> {
20-
let entries: Vec<_> = entries.collect();
21-
if entries.is_empty() {
22-
return empty();
23-
}
24-
25-
let mut shrinkers: Vec<Vec<_>> = vec![];
26-
let mut i = entries.len();
27-
loop {
28-
shrinkers.push(entries.iter().take(i).map(&f).collect());
29-
i /= 2;
30-
if i == 0 {
31-
break;
32-
}
33-
}
34-
Box::new(iter::once(Vec::new()).chain(iter::from_fn(move || loop {
35-
let mut shrinker = shrinkers.pop()?;
36-
let x: Option<Vec<A>> = shrinker.iter_mut().map(|s| s.next()).collect();
37-
if x.is_none() {
38-
continue;
39-
}
40-
shrinkers.push(shrinker);
41-
return x;
42-
})))
43-
}
44-
45-
impl<A: Arbitrary + Clone> Arbitrary for Vector<A> {
46-
fn arbitrary(u: &mut Unstructured<'_>) -> Result<Self> {
11+
impl<'a, A: Arbitrary<'a> + Clone> Arbitrary<'a> for Vector<A> {
12+
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self> {
4713
u.arbitrary_iter()?.collect()
4814
}
4915

50-
fn arbitrary_take_rest(u: Unstructured<'_>) -> Result<Self> {
16+
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self> {
5117
u.arbitrary_take_rest_iter()?.collect()
5218
}
5319

@@ -56,19 +22,14 @@ impl<A: Arbitrary + Clone> Arbitrary for Vector<A> {
5622
size_hint::and(<usize as Arbitrary>::size_hint(depth), (0, None))
5723
})
5824
}
59-
60-
fn shrink(&self) -> Box<dyn Iterator<Item = Self>> {
61-
let collections = shrink_collection(self.iter(), |x| x.shrink());
62-
Box::new(collections.map(|entries| entries.into_iter().collect()))
63-
}
6425
}
6526

66-
impl<K: Arbitrary + Ord + Clone, V: Arbitrary + Clone> Arbitrary for OrdMap<K, V> {
67-
fn arbitrary(u: &mut Unstructured<'_>) -> Result<Self> {
27+
impl<'a, K: Arbitrary<'a> + Ord + Clone, V: Arbitrary<'a> + Clone> Arbitrary<'a> for OrdMap<K, V> {
28+
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self> {
6829
u.arbitrary_iter()?.collect()
6930
}
7031

71-
fn arbitrary_take_rest(u: Unstructured<'_>) -> Result<Self> {
32+
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self> {
7233
u.arbitrary_take_rest_iter()?.collect()
7334
}
7435

@@ -77,20 +38,14 @@ impl<K: Arbitrary + Ord + Clone, V: Arbitrary + Clone> Arbitrary for OrdMap<K, V
7738
size_hint::and(<usize as Arbitrary>::size_hint(depth), (0, None))
7839
})
7940
}
80-
81-
fn shrink(&self) -> Box<dyn Iterator<Item = Self>> {
82-
let collections =
83-
shrink_collection(self.iter(), |(k, v)| Box::new(k.shrink().zip(v.shrink())));
84-
Box::new(collections.map(|entries| entries.into_iter().collect()))
85-
}
8641
}
8742

88-
impl<A: Arbitrary + Ord + Clone> Arbitrary for OrdSet<A> {
89-
fn arbitrary(u: &mut Unstructured<'_>) -> Result<Self> {
43+
impl<'a, A: Arbitrary<'a> + Ord + Clone> Arbitrary<'a> for OrdSet<A> {
44+
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self> {
9045
u.arbitrary_iter()?.collect()
9146
}
9247

93-
fn arbitrary_take_rest(u: Unstructured<'_>) -> Result<Self> {
48+
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self> {
9449
u.arbitrary_take_rest_iter()?.collect()
9550
}
9651

@@ -99,24 +54,19 @@ impl<A: Arbitrary + Ord + Clone> Arbitrary for OrdSet<A> {
9954
size_hint::and(<usize as Arbitrary>::size_hint(depth), (0, None))
10055
})
10156
}
102-
103-
fn shrink(&self) -> Box<dyn Iterator<Item = Self>> {
104-
let collections = shrink_collection(self.iter(), |v| v.shrink());
105-
Box::new(collections.map(|entries| entries.into_iter().collect()))
106-
}
10757
}
10858

109-
impl<K, V, S> Arbitrary for HashMap<K, V, S>
59+
impl<'a, K, V, S> Arbitrary<'a> for HashMap<K, V, S>
11060
where
111-
K: Arbitrary + Hash + Eq + Clone,
112-
V: Arbitrary + Clone,
61+
K: Arbitrary<'a> + Hash + Eq + Clone,
62+
V: Arbitrary<'a> + Clone,
11363
S: BuildHasher + Default + 'static,
11464
{
115-
fn arbitrary(u: &mut Unstructured<'_>) -> Result<Self> {
65+
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self> {
11666
u.arbitrary_iter()?.collect()
11767
}
11868

119-
fn arbitrary_take_rest(u: Unstructured<'_>) -> Result<Self> {
69+
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self> {
12070
u.arbitrary_take_rest_iter()?.collect()
12171
}
12272

@@ -125,24 +75,18 @@ where
12575
size_hint::and(<usize as Arbitrary>::size_hint(depth), (0, None))
12676
})
12777
}
128-
129-
fn shrink(&self) -> Box<dyn Iterator<Item = Self>> {
130-
let collections =
131-
shrink_collection(self.iter(), |(k, v)| Box::new(k.shrink().zip(v.shrink())));
132-
Box::new(collections.map(|entries| entries.into_iter().collect()))
133-
}
13478
}
13579

136-
impl<A, S> Arbitrary for HashSet<A, S>
80+
impl<'a, A, S> Arbitrary<'a> for HashSet<A, S>
13781
where
138-
A: Arbitrary + Hash + Eq + Clone,
82+
A: Arbitrary<'a> + Hash + Eq + Clone,
13983
S: BuildHasher + Default + 'static,
14084
{
141-
fn arbitrary(u: &mut Unstructured<'_>) -> Result<Self> {
85+
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self> {
14286
u.arbitrary_iter()?.collect()
14387
}
14488

145-
fn arbitrary_take_rest(u: Unstructured<'_>) -> Result<Self> {
89+
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self> {
14690
u.arbitrary_take_rest_iter()?.collect()
14791
}
14892

@@ -151,9 +95,4 @@ where
15195
size_hint::and(<usize as Arbitrary>::size_hint(depth), (0, None))
15296
})
15397
}
154-
155-
fn shrink(&self) -> Box<dyn Iterator<Item = Self>> {
156-
let collections = shrink_collection(self.iter(), |v| v.shrink());
157-
Box::new(collections.map(|entries| entries.into_iter().collect()))
158-
}
15998
}

src/quickcheck.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ use std::hash::{BuildHasher, Hash};
44
use std::iter::FromIterator;
55

66
impl<A: Arbitrary + Sync + Clone> Arbitrary for Vector<A> {
7-
fn arbitrary<G: Gen>(g: &mut G) -> Self {
7+
fn arbitrary(g: &mut Gen) -> Self {
88
Vector::from_iter(Vec::<A>::arbitrary(g))
99
}
1010
}
1111

1212
impl<K: Ord + Clone + Arbitrary + Sync, V: Clone + Arbitrary + Sync> Arbitrary for OrdMap<K, V> {
13-
fn arbitrary<G: Gen>(g: &mut G) -> Self {
13+
fn arbitrary(g: &mut Gen) -> Self {
1414
OrdMap::from_iter(Vec::<(K, V)>::arbitrary(g))
1515
}
1616
}
1717

1818
impl<A: Ord + Clone + Arbitrary + Sync> Arbitrary for OrdSet<A> {
19-
fn arbitrary<G: Gen>(g: &mut G) -> Self {
19+
fn arbitrary(g: &mut Gen) -> Self {
2020
OrdSet::from_iter(Vec::<A>::arbitrary(g))
2121
}
2222
}
@@ -26,7 +26,7 @@ where
2626
A: Hash + Eq + Arbitrary + Sync,
2727
S: BuildHasher + Default + Send + Sync + 'static,
2828
{
29-
fn arbitrary<G: Gen>(g: &mut G) -> Self {
29+
fn arbitrary(g: &mut Gen) -> Self {
3030
HashSet::from_iter(Vec::<A>::arbitrary(g))
3131
}
3232
}
@@ -37,7 +37,7 @@ where
3737
V: Arbitrary + Sync,
3838
S: BuildHasher + Default + Send + Sync + 'static,
3939
{
40-
fn arbitrary<G: Gen>(g: &mut G) -> Self {
40+
fn arbitrary(g: &mut Gen) -> Self {
4141
HashMap::from(Vec::<(K, V)>::arbitrary(g))
4242
}
4343
}

src/vector/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2525,7 +2525,7 @@ mod test {
25252525
assert!(input.ptr_eq(&inp2));
25262526
inp2.set(len - 1, 98);
25272527
assert_ne!(inp2.get(len - 1), input.get(len - 1));
2528-
assert!(!input.ptr_eq(&inp2), "{}", len);
2528+
assert!(!input.ptr_eq(&inp2));
25292529
}
25302530
}
25312531

0 commit comments

Comments
 (0)