Skip to content

Commit b726b5b

Browse files
committed
Fix clippy
1 parent 42c1384 commit b726b5b

11 files changed

+97
-133
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ name: CI
22

33
on:
44
schedule:
5-
- cron: '0 0 * * 6'
5+
- cron: "0 0 * * 6"
66
push:
77
branches:
8-
- '*'
8+
- "*"
99
pull_request:
10+
branches:
11+
- "master"
1012

1113
jobs:
1214
rustfmt:
@@ -22,15 +24,15 @@ jobs:
2224

2325
steps:
2426
- name: Checkout
25-
uses: actions/checkout@v3
27+
uses: actions/checkout@v4
2628

27-
- name: 'Setup `${{ matrix.toolchain }}`'
29+
- name: "Setup `${{ matrix.toolchain }}`"
2830
uses: dtolnay/rust-toolchain@master
2931
with:
3032
toolchain: ${{ matrix.toolchain }}
3133
components: rustfmt
3234

33-
- name: 'Override `${{ matrix.toolchain }}'
35+
- name: "Override `${{ matrix.toolchain }}"
3436
run: |
3537
rustup override set ${{ matrix.toolchain }}
3638
@@ -50,11 +52,11 @@ jobs:
5052
- stable-x86_64-apple-darwin
5153
- stable-x86_64-unknown-linux-gnu
5254
include:
53-
- { toolchain: 1.70.0-x86_64-pc-windows-msvc , os: windows-2019 }
54-
- { toolchain: 1.70.0-x86_64-apple-darwin , os: macos-11 }
55+
- { toolchain: 1.70.0-x86_64-pc-windows-msvc, os: windows-2019 }
56+
- { toolchain: 1.70.0-x86_64-apple-darwin, os: macos-11 }
5557
- { toolchain: 1.70.0-x86_64-unknown-linux-gnu, os: ubuntu-20.04 }
56-
- { toolchain: stable-x86_64-pc-windows-msvc , os: windows-2019 }
57-
- { toolchain: stable-x86_64-apple-darwin , os: macos-11 }
58+
- { toolchain: stable-x86_64-pc-windows-msvc, os: windows-2019 }
59+
- { toolchain: stable-x86_64-apple-darwin, os: macos-11 }
5860
- { toolchain: stable-x86_64-unknown-linux-gnu, os: ubuntu-20.04 }
5961

6062
name: Build (${{ matrix.toolchain }})
@@ -66,15 +68,15 @@ jobs:
6668
if: matrix.os == 'windows-2019'
6769

6870
- name: Checkout
69-
uses: actions/checkout@v3
71+
uses: actions/checkout@v4
7072

71-
- name: 'Setup `${{ matrix.toolchain }}`'
73+
- name: "Setup `${{ matrix.toolchain }}`"
7274
uses: dtolnay/rust-toolchain@master
7375
with:
7476
toolchain: ${{ matrix.toolchain }}
7577
components: clippy
7678

77-
- name: 'Override `${{ matrix.toolchain }}`'
79+
- name: "Override `${{ matrix.toolchain }}`"
7880
run: |
7981
rustup override set ${{ matrix.toolchain }}
8082
@@ -100,23 +102,23 @@ jobs:
100102
- 1.70.0-x86_64-unknown-linux-gnu
101103
- stable-x86_64-unknown-linux-gnu
102104
python-version:
103-
- '3.6' # https://packages.ubuntu.com/bionic/python3
104-
- '3.8' # https://packages.ubuntu.com/focal/python3
105+
- "3.6" # https://packages.ubuntu.com/bionic/python3
106+
- "3.8" # https://packages.ubuntu.com/focal/python3
105107

106108
name: Expand_test (${{ matrix.toolchain }}, ${{ matrix.python-version }})
107109
runs-on: ubuntu-20.04
108110

109111
steps:
110112
- name: Checkout
111-
uses: actions/checkout@v3
113+
uses: actions/checkout@v4
112114

113-
- name: 'Setup `${{ matrix.toolchain }}`'
115+
- name: "Setup `${{ matrix.toolchain }}`"
114116
uses: dtolnay/rust-toolchain@master
115117
with:
116118
toolchain: ${{ matrix.toolchain }}
117119
components: rustfmt
118120

119-
- name: 'Override `${{ matrix.toolchain }}`'
121+
- name: "Override `${{ matrix.toolchain }}`"
120122
run: |
121123
rustup override set ${{ matrix.toolchain }}
122124
@@ -134,21 +136,21 @@ jobs:
134136

135137
steps:
136138
- name: Checkout
137-
uses: actions/checkout@v3
139+
uses: actions/checkout@v4
138140

139141
- name: Setup `1.70.0-x86_64-unknown-linux-gnu`
140142
uses: dtolnay/rust-toolchain@master
141143
with:
142144
toolchain: 1.70.0-x86_64-unknown-linux-gnu
143145

144-
- name: 'Override `1.70.0-x86_64-unknown-linux-gnu'
146+
- name: "Override `1.70.0-x86_64-unknown-linux-gnu"
145147
run: |
146148
rustup override set 1.70.0-x86_64-unknown-linux-gnu
147149
148150
- name: Setup Python 3.9
149151
uses: actions/setup-python@v4
150152
with:
151-
python-version: '3.9'
153+
python-version: "3.9"
152154

153155
- name: Install `oj`
154156
run: pip install online-judge-tools

src/convolution.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,13 +391,13 @@ mod tests {
391391
}
392392

393393
for i in 0..1000 {
394-
let a = vec![i64::min_value() + i];
394+
let a = vec![i64::MIN + i];
395395
let b = vec![1];
396396
assert_eq!(a, super::convolution_i64(&a, &b));
397397
}
398398

399399
for i in 0..1000 {
400-
let a = vec![i64::max_value() - i];
400+
let a = vec![i64::MAX - i];
401401
let b = vec![1];
402402
assert_eq!(a, super::convolution_i64(&a, &b));
403403
}

src/internal_bit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ mod tests {
2525
assert_eq!(30, super::ceil_pow2(1 << 30));
2626
assert_eq!(31, super::ceil_pow2((1 << 30) + 1));
2727

28-
assert_eq!(32, super::ceil_pow2(u32::max_value()));
28+
assert_eq!(32, super::ceil_pow2(u32::MAX));
2929
}
3030
}

src/internal_math.rs

Lines changed: 36 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ pub(crate) struct Barrett {
2727
impl Barrett {
2828
/// # Arguments
2929
/// * `m` `1 <= m`
30-
/// (Note: `m <= 2^31` should also hold, which is undocumented in the original library.
31-
/// See the [pull reqeust commment](https://github.com/rust-lang-ja/ac-library-rs/pull/3#discussion_r484661007)
32-
/// for more details.)
30+
/// (Note: `m <= 2^31` should also hold, which is undocumented in the original library.
31+
/// See the [pull reqeust commment](https://github.com/rust-lang-ja/ac-library-rs/pull/3#discussion_r484661007)
32+
/// for more details.)
3333
pub(crate) fn new(m: u32) -> Barrett {
3434
Barrett {
3535
_m: m,
@@ -208,7 +208,7 @@ pub(crate) fn primitive_root(m: i32) -> i32 {
208208
while x % 2 == 0 {
209209
x /= 2;
210210
}
211-
for i in (3..std::i32::MAX).step_by(2) {
211+
for i in (3..i32::MAX).step_by(2) {
212212
if i as i64 * i as i64 > x as i64 {
213213
break;
214214
}
@@ -328,55 +328,49 @@ mod tests {
328328
assert_eq!(pow_mod(0, 0, 3), 1);
329329
assert_eq!(pow_mod(0, 0, 723), 1);
330330
assert_eq!(pow_mod(0, 0, 998244353), 1);
331-
assert_eq!(pow_mod(0, 0, i32::max_value()), 1);
331+
assert_eq!(pow_mod(0, 0, i32::MAX), 1);
332332

333333
assert_eq!(pow_mod(0, 1, 1), 0);
334334
assert_eq!(pow_mod(0, 1, 3), 0);
335335
assert_eq!(pow_mod(0, 1, 723), 0);
336336
assert_eq!(pow_mod(0, 1, 998244353), 0);
337-
assert_eq!(pow_mod(0, 1, i32::max_value()), 0);
337+
assert_eq!(pow_mod(0, 1, i32::MAX), 0);
338338

339-
assert_eq!(pow_mod(0, i64::max_value(), 1), 0);
340-
assert_eq!(pow_mod(0, i64::max_value(), 3), 0);
341-
assert_eq!(pow_mod(0, i64::max_value(), 723), 0);
342-
assert_eq!(pow_mod(0, i64::max_value(), 998244353), 0);
343-
assert_eq!(pow_mod(0, i64::max_value(), i32::max_value()), 0);
339+
assert_eq!(pow_mod(0, i64::MAX, 1), 0);
340+
assert_eq!(pow_mod(0, i64::MAX, 3), 0);
341+
assert_eq!(pow_mod(0, i64::MAX, 723), 0);
342+
assert_eq!(pow_mod(0, i64::MAX, 998244353), 0);
343+
assert_eq!(pow_mod(0, i64::MAX, i32::MAX), 0);
344344

345345
assert_eq!(pow_mod(1, 0, 1), 0);
346346
assert_eq!(pow_mod(1, 0, 3), 1);
347347
assert_eq!(pow_mod(1, 0, 723), 1);
348348
assert_eq!(pow_mod(1, 0, 998244353), 1);
349-
assert_eq!(pow_mod(1, 0, i32::max_value()), 1);
349+
assert_eq!(pow_mod(1, 0, i32::MAX), 1);
350350

351351
assert_eq!(pow_mod(1, 1, 1), 0);
352352
assert_eq!(pow_mod(1, 1, 3), 1);
353353
assert_eq!(pow_mod(1, 1, 723), 1);
354354
assert_eq!(pow_mod(1, 1, 998244353), 1);
355-
assert_eq!(pow_mod(1, 1, i32::max_value()), 1);
356-
357-
assert_eq!(pow_mod(1, i64::max_value(), 1), 0);
358-
assert_eq!(pow_mod(1, i64::max_value(), 3), 1);
359-
assert_eq!(pow_mod(1, i64::max_value(), 723), 1);
360-
assert_eq!(pow_mod(1, i64::max_value(), 998244353), 1);
361-
assert_eq!(pow_mod(1, i64::max_value(), i32::max_value()), 1);
362-
363-
assert_eq!(pow_mod(i64::max_value(), 0, 1), 0);
364-
assert_eq!(pow_mod(i64::max_value(), 0, 3), 1);
365-
assert_eq!(pow_mod(i64::max_value(), 0, 723), 1);
366-
assert_eq!(pow_mod(i64::max_value(), 0, 998244353), 1);
367-
assert_eq!(pow_mod(i64::max_value(), 0, i32::max_value()), 1);
368-
369-
assert_eq!(pow_mod(i64::max_value(), i64::max_value(), 1), 0);
370-
assert_eq!(pow_mod(i64::max_value(), i64::max_value(), 3), 1);
371-
assert_eq!(pow_mod(i64::max_value(), i64::max_value(), 723), 640);
372-
assert_eq!(
373-
pow_mod(i64::max_value(), i64::max_value(), 998244353),
374-
683296792
375-
);
376-
assert_eq!(
377-
pow_mod(i64::max_value(), i64::max_value(), i32::max_value()),
378-
1
379-
);
355+
assert_eq!(pow_mod(1, 1, i32::MAX), 1);
356+
357+
assert_eq!(pow_mod(1, i64::MAX, 1), 0);
358+
assert_eq!(pow_mod(1, i64::MAX, 3), 1);
359+
assert_eq!(pow_mod(1, i64::MAX, 723), 1);
360+
assert_eq!(pow_mod(1, i64::MAX, 998244353), 1);
361+
assert_eq!(pow_mod(1, i64::MAX, i32::MAX), 1);
362+
363+
assert_eq!(pow_mod(i64::MAX, 0, 1), 0);
364+
assert_eq!(pow_mod(i64::MAX, 0, 3), 1);
365+
assert_eq!(pow_mod(i64::MAX, 0, 723), 1);
366+
assert_eq!(pow_mod(i64::MAX, 0, 998244353), 1);
367+
assert_eq!(pow_mod(i64::MAX, 0, i32::MAX), 1);
368+
369+
assert_eq!(pow_mod(i64::MAX, i64::MAX, 1), 0);
370+
assert_eq!(pow_mod(i64::MAX, i64::MAX, 3), 1);
371+
assert_eq!(pow_mod(i64::MAX, i64::MAX, 723), 640);
372+
assert_eq!(pow_mod(i64::MAX, i64::MAX, 998244353), 683296792);
373+
assert_eq!(pow_mod(i64::MAX, i64::MAX, i32::MAX), 1);
380374

381375
assert_eq!(pow_mod(2, 3, 1_000_000_007), 8);
382376
assert_eq!(pow_mod(5, 7, 1_000_000_007), 78125);
@@ -409,7 +403,7 @@ mod tests {
409403
assert!(!is_prime(1_000_000_000));
410404
assert!(is_prime(1_000_000_007));
411405

412-
assert!(is_prime(i32::max_value()));
406+
assert!(is_prime(i32::MAX));
413407
}
414408

415409
#[test]
@@ -442,8 +436,8 @@ mod tests {
442436
(57, 81, 3),
443437
(12345, 67890, 15),
444438
(-3141592 * 6535, 3141592 * 8979, 3141592),
445-
(i64::max_value(), i64::max_value(), i64::max_value()),
446-
(i64::min_value(), i64::max_value(), 1),
439+
(i64::MAX, i64::MAX, i64::MAX),
440+
(i64::MIN, i64::MAX, 1),
447441
] {
448442
let (g_, x) = inv_gcd(a, b);
449443
assert_eq!(g, g_);
@@ -454,25 +448,15 @@ mod tests {
454448

455449
#[test]
456450
fn test_primitive_root() {
457-
for &p in &[
458-
2,
459-
3,
460-
5,
461-
7,
462-
233,
463-
200003,
464-
998244353,
465-
1_000_000_007,
466-
i32::max_value(),
467-
] {
451+
for &p in &[2, 3, 5, 7, 233, 200003, 998244353, 1_000_000_007, i32::MAX] {
468452
assert!(is_prime(p));
469453
let g = primitive_root(p);
470454
if p != 2 {
471455
assert_ne!(g, 1);
472456
}
473457

474458
let q = p - 1;
475-
for i in (2..i32::max_value()).take_while(|i| i * i <= q) {
459+
for i in (2..i32::MAX).take_while(|i| i * i <= q) {
476460
if q % i != 0 {
477461
break;
478462
}

src/internal_type_traits.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,14 @@ macro_rules! impl_integral {
9999
impl BoundedBelow for $ty {
100100
#[inline]
101101
fn min_value() -> Self {
102-
Self::min_value()
102+
Self::MIN
103103
}
104104
}
105105

106106
impl BoundedAbove for $ty {
107107
#[inline]
108108
fn max_value() -> Self {
109-
Self::max_value()
109+
Self::MAX
110110
}
111111
}
112112

src/lazysegtree.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ mod tests {
382382
check_segtree(&base, &mut segtree);
383383

384384
let mut segtree = LazySegtree::<MaxAdd>::new(n);
385-
let mut internal = vec![i32::min_value(); n];
385+
let mut internal = vec![i32::MIN; n];
386386
for i in 0..n {
387387
segtree.set(i, base[i]);
388388
internal[i] = base[i];
@@ -435,31 +435,23 @@ mod tests {
435435
}
436436
assert_eq!(
437437
segtree.all_prod(),
438-
base.iter().max().copied().unwrap_or(i32::min_value())
438+
base.iter().max().copied().unwrap_or(i32::MIN)
439439
);
440440
for k in 0..=10 {
441441
let f = |x| x < k;
442442
for i in 0..=n {
443443
assert_eq!(
444444
Some(segtree.max_right(i, f)),
445445
(i..=n)
446-
.filter(|&j| f(base[i..j]
447-
.iter()
448-
.max()
449-
.copied()
450-
.unwrap_or(i32::min_value())))
446+
.filter(|&j| f(base[i..j].iter().max().copied().unwrap_or(i32::MIN)))
451447
.max()
452448
);
453449
}
454450
for j in 0..=n {
455451
assert_eq!(
456452
Some(segtree.min_left(j, f)),
457453
(0..=j)
458-
.filter(|&i| f(base[i..j]
459-
.iter()
460-
.max()
461-
.copied()
462-
.unwrap_or(i32::min_value())))
454+
.filter(|&i| f(base[i..j].iter().max().copied().unwrap_or(i32::MIN)))
463455
.min()
464456
);
465457
}
@@ -473,7 +465,7 @@ mod tests {
473465
.filter_map(|(i, a)| Some(a).filter(|_| range.contains(&i)))
474466
.max()
475467
.copied()
476-
.unwrap_or(i32::min_value());
468+
.unwrap_or(i32::MIN);
477469
assert_eq!(segtree.prod(range), expected);
478470
}
479471
}

0 commit comments

Comments
 (0)