Skip to content

Commit d6ac642

Browse files
authored
Merge pull request #1 from smartyalgo/fix/rand-upgrade
fix(deps): upgrade rand 0.8→0.9 and rand_chacha 0.3→0.9
2 parents 8d23f19 + 2951396 commit d6ac642

89 files changed

Lines changed: 6233 additions & 4322 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci_check.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ jobs:
1010
ci_check:
1111
runs-on: 'ubuntu-latest'
1212
steps:
13-
- uses: 'actions/checkout@v2'
14-
- uses: 'actions/setup-java@v3'
13+
- uses: 'actions/checkout@v4'
14+
- uses: 'actions/setup-java@v4'
1515
with:
1616
distribution: 'liberica'
1717
java-version: '20'
18-
- uses: 'actions/cache@v2'
18+
- uses: 'actions/cache@v4'
1919
with:
2020
path: |
2121
~/.rustup/toolchains
@@ -114,4 +114,4 @@ jobs:
114114
- name: 'check toad-string'
115115
run: 'cargo make ci'
116116
if: github.ref == 'refs/heads/main' || steps.package_changed.outputs.toad-string == 'true'
117-
working-directory: 'toad-map'
117+
working-directory: 'toad-string'

.github/workflows/release-please.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ jobs:
1010
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: google-github-actions/release-please-action@v3
13+
- uses: google-github-actions/release-please-action@v4
1414
id: release
1515
with:
1616
token: ${{secrets.RELEASE_PLEASE_GITHUB_TOKEN}}
17-
sequential-calls: true
18-
command: manifest
17+
config-file: release-please-config.json
18+
manifest-file: .release-please-manifest.json
1919

20-
- uses: actions/checkout@v2
20+
- uses: actions/checkout@v4
2121
if: ${{ steps.release.outputs.releases_created }}
2222

23-
- uses: actions/cache@v2
23+
- uses: actions/cache@v4
2424
if: ${{ steps.release.outputs.releases_created }}
2525
with:
2626
path: |

toad-array/src/lib.rs

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ use toad_len::Len;
3636

3737
/// Operations on ordered indexed collections
3838
pub trait Indexed<T>
39-
where Self: Len + Deref<Target = [T]>
39+
where
40+
Self: Len + Deref<Target = [T]>,
4041
{
4142
/// Insert a new element at `ix`, shifting all other elements to the right.
4243
///
@@ -181,7 +182,8 @@ pub trait Indexed<T>
181182
/// assert_eq!(v, vec![5]);
182183
/// ```
183184
fn drop_while<F>(&mut self, f: F)
184-
where F: for<'a> Fn(&'a T) -> bool
185+
where
186+
F: for<'a> Fn(&'a T) -> bool,
185187
{
186188
match self.get(0) {
187189
| Some(t) if !f(&t) => return,
@@ -200,7 +202,8 @@ pub trait Indexed<T>
200202
/// - `Vec` is `Reserve`, and invokes `Vec::with_capacity`
201203
/// - `tinyvec::ArrayVec` is `Reserve` and invokes `Default::default()` because creating an `ArrayVec` automatically allocates the required space on the stack.
202204
pub trait Reserve
203-
where Self: Default
205+
where
206+
Self: Default,
204207
{
205208
/// Create an instance of the collection with a given capacity.
206209
///
@@ -218,7 +221,8 @@ pub trait Reserve
218221
///
219222
/// If self was longer, drops elements up to `len`
220223
pub trait Trunc
221-
where Self: Sized
224+
where
225+
Self: Sized,
222226
{
223227
#[allow(missing_docs)]
224228
fn trunc(&mut self, len: usize) -> ();
@@ -236,7 +240,9 @@ impl<T> Trunc for Vec<T> {
236240
}
237241
}
238242

239-
impl<T, const N: usize> Trunc for tinyvec::ArrayVec<[T; N]> where T: Default
243+
impl<T, const N: usize> Trunc for tinyvec::ArrayVec<[T; N]>
244+
where
245+
T: Default,
240246
{
241247
fn trunc(&mut self, len: usize) -> () {
242248
self.truncate(len)
@@ -251,21 +257,24 @@ impl<T, const N: usize> Trunc for tinyvec::ArrayVec<[T; N]> where T: Default
251257
pub trait Filled<T>: Sized {
252258
#[allow(missing_docs)]
253259
fn filled(t: T) -> Option<Self>
254-
where T: Copy
260+
where
261+
T: Copy,
255262
{
256263
Self::filled_using(|| t)
257264
}
258265

259266
#[allow(missing_docs)]
260267
fn filled_default() -> Option<Self>
261-
where T: Default
268+
where
269+
T: Default,
262270
{
263271
Self::filled_using(|| Default::default())
264272
}
265273

266274
#[allow(missing_docs)]
267275
fn filled_using<F>(f: F) -> Option<Self>
268-
where F: Fn() -> T;
276+
where
277+
F: Fn() -> T;
269278
}
270279

271280
#[cfg(feature = "alloc")]
@@ -278,24 +287,29 @@ impl<T> Reserve for Vec<T> {
278287
#[cfg(feature = "alloc")]
279288
impl<T> Filled<T> for Vec<T> {
280289
fn filled_using<F>(_: F) -> Option<Self>
281-
where F: Fn() -> T
290+
where
291+
F: Fn() -> T,
282292
{
283293
None
284294
}
285295
}
286296

287297
impl<A: tinyvec::Array> Reserve for tinyvec::ArrayVec<A> {}
288298

289-
impl<T, const N: usize> Filled<T> for tinyvec::ArrayVec<[T; N]> where T: Default
299+
impl<T, const N: usize> Filled<T> for tinyvec::ArrayVec<[T; N]>
300+
where
301+
T: Default,
290302
{
291303
fn filled_using<F>(f: F) -> Option<Self>
292-
where F: Fn() -> T
304+
where
305+
F: Fn() -> T,
293306
{
294307
Some(core::iter::repeat(()).take(N).map(|_| f()).collect())
295308
}
296309

297310
fn filled(t: T) -> Option<Self>
298-
where T: Copy
311+
where
312+
T: Copy,
299313
{
300314
Some(Self::from([t; N]))
301315
}
@@ -347,7 +361,8 @@ pub trait Array:
347361

348362
/// Collections that support extending themselves mutably from copyable slices
349363
pub trait AppendCopy<T>
350-
where T: Copy
364+
where
365+
T: Copy,
351366
{
352367
/// Extend self mutably, copying from a slice.
353368
///
@@ -360,16 +375,19 @@ pub trait AppendCopy<T>
360375
}
361376

362377
#[cfg(feature = "alloc")]
363-
impl<T> AppendCopy<T> for Vec<T> where T: Copy
378+
impl<T> AppendCopy<T> for Vec<T>
379+
where
380+
T: Copy,
364381
{
365382
fn append_copy(&mut self, i: &[T]) {
366383
self.extend(i);
367384
}
368385
}
369386

370387
impl<T, A> AppendCopy<T> for tinyvec::ArrayVec<A>
371-
where T: Copy,
372-
A: tinyvec::Array<Item = T>
388+
where
389+
T: Copy,
390+
A: tinyvec::Array<Item = T>,
373391
{
374392
fn append_copy(&mut self, i: &[T]) {
375393
self.extend_from_slice(i);
@@ -397,15 +415,17 @@ impl<T> Indexed<T> for Vec<T> {
397415
}
398416

399417
impl<A, T> Array for tinyvec::ArrayVec<A>
400-
where Self: Filled<T> + Trunc,
401-
A: tinyvec::Array<Item = T>
418+
where
419+
Self: Filled<T> + Trunc,
420+
A: tinyvec::Array<Item = T>,
402421
{
403422
type Item = T;
404423
}
405424

406425
impl<A> Indexed<A::Item> for tinyvec::ArrayVec<A>
407-
where Self: Filled<A::Item> + Trunc,
408-
A: tinyvec::Array
426+
where
427+
Self: Filled<A::Item> + Trunc,
428+
A: tinyvec::Array,
409429
{
410430
fn insert(&mut self, ix: usize, t: A::Item) {
411431
tinyvec::ArrayVec::insert(self, ix, t)

toad-common/src/array.rs

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ pub trait Reserve: Default {
103103
///
104104
/// If self was longer, drops elements up to `len`
105105
pub trait Trunc
106-
where Self: Sized
106+
where
107+
Self: Sized,
107108
{
108109
#[allow(missing_docs)]
109110
fn trunc(&mut self, len: usize) -> ();
@@ -121,7 +122,9 @@ impl<T> Trunc for Vec<T> {
121122
}
122123
}
123124

124-
impl<T, const N: usize> Trunc for tinyvec::ArrayVec<[T; N]> where T: Default
125+
impl<T, const N: usize> Trunc for tinyvec::ArrayVec<[T; N]>
126+
where
127+
T: Default,
125128
{
126129
fn trunc(&mut self, len: usize) -> () {
127130
self.truncate(len)
@@ -136,21 +139,24 @@ impl<T, const N: usize> Trunc for tinyvec::ArrayVec<[T; N]> where T: Default
136139
pub trait Filled<T>: Sized {
137140
#[allow(missing_docs)]
138141
fn filled(t: T) -> Option<Self>
139-
where T: Copy
142+
where
143+
T: Copy,
140144
{
141145
Self::filled_using(|| t)
142146
}
143147

144148
#[allow(missing_docs)]
145149
fn filled_default() -> Option<Self>
146-
where T: Default
150+
where
151+
T: Default,
147152
{
148153
Self::filled_using(|| Default::default())
149154
}
150155

151156
#[allow(missing_docs)]
152157
fn filled_using<F>(f: F) -> Option<Self>
153-
where F: Fn() -> T;
158+
where
159+
F: Fn() -> T;
154160
}
155161

156162
#[cfg(feature = "alloc")]
@@ -163,24 +169,29 @@ impl<T> Reserve for Vec<T> {
163169
#[cfg(feature = "alloc")]
164170
impl<T> Filled<T> for Vec<T> {
165171
fn filled_using<F>(_: F) -> Option<Self>
166-
where F: Fn() -> T
172+
where
173+
F: Fn() -> T,
167174
{
168175
None
169176
}
170177
}
171178

172179
impl<A: tinyvec::Array> Reserve for tinyvec::ArrayVec<A> {}
173180

174-
impl<T, const N: usize> Filled<T> for tinyvec::ArrayVec<[T; N]> where T: Default
181+
impl<T, const N: usize> Filled<T> for tinyvec::ArrayVec<[T; N]>
182+
where
183+
T: Default,
175184
{
176185
fn filled_using<F>(f: F) -> Option<Self>
177-
where F: Fn() -> T
186+
where
187+
F: Fn() -> T,
178188
{
179189
Some(core::iter::repeat(()).take(N).map(|_| f()).collect())
180190
}
181191

182192
fn filled(t: T) -> Option<Self>
183-
where T: Copy
193+
where
194+
T: Copy,
184195
{
185196
Some(Self::from([t; N]))
186197
}
@@ -282,7 +293,9 @@ impl<T> Array for Vec<T> {
282293
}
283294
}
284295

285-
impl<A: tinyvec::Array<Item = T>, T> Array for tinyvec::ArrayVec<A> where Self: Filled<T> + Trunc
296+
impl<A: tinyvec::Array<Item = T>, T> Array for tinyvec::ArrayVec<A>
297+
where
298+
Self: Filled<T> + Trunc,
286299
{
287300
type Item = T;
288301

toad-common/src/cursor.rs

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -73,25 +73,22 @@ impl<T: AsRef<[u8]>> Cursor<T> {
7373
#[allow(clippy::should_implement_trait)]
7474
pub fn next(&mut self) -> Option<u8> {
7575
self.take_exact(1).and_then(|a| match a {
76-
| &[a] => Some(a),
77-
| _ => None,
78-
})
76+
| &[a] => Some(a),
77+
| _ => None,
78+
})
7979
}
8080

8181
/// Take `n` bytes from the cursor, stopping early if
8282
/// the end of the buffer is encountered.
8383
///
8484
/// Runs in O(1) time.
8585
pub fn take(&mut self, n: usize) -> &[u8] {
86-
Self::peek_(self.len, self.cursor, &self.t, n).map(|a| {
87-
Self::skip_(&mut self.cursor, self.len, n);
88-
a
89-
})
90-
.unwrap_or_else(|| {
91-
Self::take_until_end_(&mut self.cursor,
92-
self.len,
93-
&self.t)
94-
})
86+
Self::peek_(self.len, self.cursor, &self.t, n)
87+
.map(|a| {
88+
Self::skip_(&mut self.cursor, self.len, n);
89+
a
90+
})
91+
.unwrap_or_else(|| Self::take_until_end_(&mut self.cursor, self.len, &self.t))
9592
}
9693

9794
/// Take `n` bytes from the cursor, returning None if
@@ -100,9 +97,9 @@ impl<T: AsRef<[u8]>> Cursor<T> {
10097
/// Runs in O(1) time.
10198
pub fn take_exact(&mut self, n: usize) -> Option<&[u8]> {
10299
Self::peek_(self.len, self.cursor, &self.t, n).map(|a| {
103-
Self::skip_(&mut self.cursor, self.len, n);
104-
a
105-
})
100+
Self::skip_(&mut self.cursor, self.len, n);
101+
a
102+
})
106103
}
107104

108105
/// Without advancing the position, look at the next
@@ -143,15 +140,16 @@ impl<T: AsRef<[u8]>> Cursor<T> {
143140
return &[];
144141
}
145142

146-
(self.cursor..self.len).into_iter()
147-
.take_while(|ix| f(self.t.as_ref()[*ix]))
148-
.last()
149-
.map(|end_ix| {
150-
let out = &self.t.as_ref()[self.cursor..=end_ix];
151-
self.cursor = end_ix + 1;
152-
out
153-
})
154-
.unwrap_or(&[])
143+
(self.cursor..self.len)
144+
.into_iter()
145+
.take_while(|ix| f(self.t.as_ref()[*ix]))
146+
.last()
147+
.map(|end_ix| {
148+
let out = &self.t.as_ref()[self.cursor..=end_ix];
149+
self.cursor = end_ix + 1;
150+
out
151+
})
152+
.unwrap_or(&[])
155153
}
156154

157155
/// Whether the cursor has reached the end
@@ -269,8 +267,9 @@ mod tests {
269267
#[test]
270268
pub fn take_while() {
271269
let til_slash = |c: &mut Cursor<&str>| {
272-
core::str::from_utf8(c.take_while(|b| (b as char) != '/')).unwrap()
273-
.to_string()
270+
core::str::from_utf8(c.take_while(|b| (b as char) != '/'))
271+
.unwrap()
272+
.to_string()
274273
};
275274

276275
let mut cur = Cursor::new("abc/def");

0 commit comments

Comments
 (0)