Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update toolchain to 1.82.0 #220

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/setup-rust/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ runs:
- name: Rust Toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: "1.70.0"
toolchain: "1.82.0"

- uses: taiki-e/install-action@nextest

Expand Down
4 changes: 2 additions & 2 deletions libs/accum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,13 @@ mod tests {
#[test]
fn test_skipped_min() {
let a = vec![4, 2, 6, 1];
let skipped = skipped_min(&a, std::i32::MAX);
let skipped = skipped_min(&a, i32::MAX);
assert_eq!(skipped, vec![1, 1, 1, 2]);
}
#[test]
fn test_skipped_max() {
let a = vec![4, 2, 6, 1];
let skipped = skipped_max(&a, std::i32::MIN);
let skipped = skipped_max(&a, i32::MIN);
assert_eq!(skipped, vec![6, 6, 4, 6]);
}
}
20 changes: 10 additions & 10 deletions libs/bfs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ pub fn tree_diamter_restore(g: &[Vec<usize>]) -> (Vec<usize>, u32) {

/// 一点からの距離配列を作ります。
pub fn calc_dist(start: usize, g: &[Vec<usize>]) -> Vec<u32> {
let mut dist = vec![std::u32::MAX; g.len()];
let mut dist = vec![u32::MAX; g.len()];
dist[start] = 0;
let mut queue = VecDeque::from(vec![start]);
while let Some(x) = queue.pop_front() {
for &y in &g[x] {
if dist[y] == std::u32::MAX {
if dist[y] == u32::MAX {
dist[y] = dist[x] + 1;
queue.push_back(y);
}
Expand All @@ -49,14 +49,14 @@ pub fn calc_dist(start: usize, g: &[Vec<usize>]) -> Vec<u32> {

/// 一点からの距離配列と、前者配列を作ります。始点の前者は自分自身です。
pub fn calc_dist_restore(start: usize, g: &[Vec<usize>]) -> (Vec<u32>, Vec<usize>) {
let mut dist = vec![std::u32::MAX; g.len()];
let mut prv = vec![std::usize::MAX; g.len()];
let mut dist = vec![u32::MAX; g.len()];
let mut prv = vec![usize::MAX; g.len()];
dist[start] = 0;
prv[start] = start;
let mut queue = VecDeque::from(vec![start]);
while let Some(x) = queue.pop_front() {
for &y in &g[x] {
if dist[y] == std::u32::MAX {
if dist[y] == u32::MAX {
dist[y] = dist[x] + 1;
prv[y] = x;
queue.push_back(y);
Expand All @@ -69,7 +69,7 @@ pub fn calc_dist_restore(start: usize, g: &[Vec<usize>]) -> (Vec<u32>, Vec<usize
/// start から end が到達可能ならば最短経路の頂点列を返し、不能ならば `None` を返します。
pub fn find_path(start: usize, end: usize, g: &[Vec<usize>]) -> Option<Vec<usize>> {
let (dist, prv) = calc_dist_restore(start, g);
if dist[end] == std::u32::MAX {
if dist[end] == u32::MAX {
None
} else {
let mut res = vec![end];
Expand Down Expand Up @@ -124,7 +124,7 @@ mod tests {
if let Some(path) = path {
validate_path(&dist, &path, start, end);
} else {
assert_eq!(dist[end], std::u32::MAX);
assert_eq!(dist[end], u32::MAX);
}
}
}
Expand All @@ -143,7 +143,7 @@ mod tests {
fn validate_prv(dist: &[u32], prv: &[usize], start: usize) {
assert_eq!(prv[start], start);
(0..dist.len())
.filter(|&i| i != start && prv[i] != std::usize::MAX)
.filter(|&i| i != start && prv[i] != usize::MAX)
.for_each(|i| assert_eq!(dist[prv[i]] + 1, dist[i]))
}

Expand Down Expand Up @@ -185,7 +185,7 @@ mod tests {

fn brute_tree_diameter(g: &[Vec<usize>]) -> ([usize; 2], u32) {
let n = g.len();
let mut dist = vec![vec![std::u32::MAX; n]; n];
let mut dist = vec![vec![u32::MAX; n]; n];
(0..n).for_each(|i| dist[i][i] = 0);
g.iter()
.enumerate()
Expand All @@ -202,7 +202,7 @@ mod tests {
}
}
}
assert!(dist.iter().flatten().all(|&x| x != std::u32::MAX));
assert!(dist.iter().flatten().all(|&x| x != u32::MAX));
dist.iter()
.enumerate()
.flat_map(|(i, v)| v.iter().copied().enumerate().map(move |(j, x)| (i, j, x)))
Expand Down
10 changes: 5 additions & 5 deletions libs/bfs01/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub enum Weight {

/// 一点からの距離配列を作ります。
pub fn calc_dist(s: usize, g: &[Vec<(usize, Weight)>]) -> Vec<u32> {
let mut dist = vec![std::u32::MAX; g.len()];
let mut dist = vec![u32::MAX; g.len()];
dist[s] = 0;
let mut queue = VecDeque::from(vec![s]);
while let Some(x) = queue.pop_front() {
Expand All @@ -32,8 +32,8 @@ pub fn calc_dist(s: usize, g: &[Vec<(usize, Weight)>]) -> Vec<u32> {

/// 一点からの距離配列と、前者配列を作ります。始点の前者は自分自身です。
pub fn calc_dist_restore(s: usize, g: &[Vec<(usize, Weight)>]) -> (Vec<u32>, Vec<usize>) {
let mut dist = vec![std::u32::MAX; g.len()];
let mut prv = vec![std::usize::MAX; g.len()];
let mut dist = vec![u32::MAX; g.len()];
let mut prv = vec![usize::MAX; g.len()];
prv[s] = s;
dist[s] = 0;
let mut queue = VecDeque::from(vec![s]);
Expand Down Expand Up @@ -124,8 +124,8 @@ mod tests {
fn validate_dist_prv(dist: &[u32], prv: &[usize], s: usize) {
assert_eq!(prv[s], s);
prv.iter().copied().enumerate().for_each(|(x, p)| {
if p == std::usize::MAX {
assert_eq!(dist[x], std::u32::MAX);
if p == usize::MAX {
assert_eq!(dist[x], u32::MAX);
} else {
assert!(dist[p] == dist[x] || dist[p] + 1 == dist[x])
}
Expand Down
8 changes: 4 additions & 4 deletions libs/bitvec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,12 @@ impl<'a> IntoIterator for &'a BitVec {
}
impl Debug for BitVec {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.to_string())
write!(f, "{}", self)
}
}
impl ToString for BitVec {
fn to_string(&self) -> String {
self.format('1', '0')
impl std::fmt::Display for BitVec {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.format('1', '0'))
}
}

Expand Down
3 changes: 2 additions & 1 deletion libs/bsgs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
//! * ちなみに位数の上界は、探索の打ち切りに用いています。
//! * 群の演算は、モジュラス等が動的に与えられる可能性を考えて、型ではなくオブジェクトにしました。
//! * たいてい ℤ / n ℤ
//! の乗法群にしか使わない気がするのですが、それようのユーティルがうまく作れず……
//! の乗法群にしか使わない気がするのですが、それようのユーティルがうまく作れず……
use std::collections::HashMap;
use std::fmt::Debug;
use std::fmt::Formatter;
Expand Down Expand Up @@ -124,6 +124,7 @@ where
}
}

#[allow(clippy::missing_fields_in_debug)]
impl<T: Debug, Mul> Debug for Bsgs<T, Mul> {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
f.debug_struct("Bsgs")
Expand Down
24 changes: 13 additions & 11 deletions libs/cht/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@
use std::borrow::Borrow;
use std::collections::BTreeSet;
use std::fmt::Debug;
use std::i64::MAX;
use std::i64::MIN;
use std::marker::PhantomData;
use std::ops::Add;
use std::ops::Mul;
Expand Down Expand Up @@ -151,7 +149,7 @@ impl<C: ConvexOrConcave> VecCht<C> {

while let Some(seg) = self.vec.pop() {
let Min(x) = seg.min;
if x == MIN || line.eval(x) < seg.line.eval(x) {
if x == i64::MIN || line.eval(x) < seg.line.eval(x) {
self.vec.push(seg);
break;
}
Expand All @@ -170,11 +168,11 @@ impl<C: ConvexOrConcave> VecCht<C> {
}
}
}
let min = Min(self.vec.last().map_or(MIN, |seg| seg.max.0));
let min = Min(self.vec.last().map_or(i64::MIN, |seg| seg.max.0));
self.vec.push(Segment {
line,
min,
max: Max(MAX),
max: Max(i64::MAX),
});
}
}
Expand Down Expand Up @@ -221,8 +219,8 @@ impl<C: ConvexOrConcave> BTreeCht<C> {
let line = Line { p, q };
if let Some(seg) = self.set.range(p..).next() {
let Min(x) = seg.min;
if x == MIN && seg.line.p == p && seg.line.q <= q
|| x != MIN && line.eval(x) <= seg.line.eval(x)
if x == i64::MIN && seg.line.p == p && seg.line.q <= q
|| x != i64::MIN && line.eval(x) <= seg.line.eval(x)
{
return;
}
Expand All @@ -232,14 +230,14 @@ impl<C: ConvexOrConcave> BTreeCht<C> {

while let Some(&seg) = self.set.range(..p).next_back() {
let Min(x) = seg.min;
if x == MIN || line.eval(x) < seg.line.eval(x) {
if x == i64::MIN || line.eval(x) < seg.line.eval(x) {
break;
}
self.set.remove(&seg);
}
while let Some(&seg) = self.set.range(p..).next() {
let Max(x) = seg.max;
if x == MAX || line.eval(x) < seg.line.eval(x) {
if x == i64::MAX || line.eval(x) < seg.line.eval(x) {
break;
}
self.set.remove(&seg);
Expand Down Expand Up @@ -274,8 +272,12 @@ impl<C: ConvexOrConcave> BTreeCht<C> {
}
};
}
let min = Min(self.set.range(..p).next_back().map_or(MIN, |seg| seg.max.0));
let max = Max(self.set.range(p..).next().map_or(MAX, |seg| seg.min.0));
let min = Min(self
.set
.range(..p)
.next_back()
.map_or(i64::MIN, |seg| seg.max.0));
let max = Max(self.set.range(p..).next().map_or(i64::MAX, |seg| seg.min.0));
if min.0 < max.0 {
self.set.insert(Segment { line, min, max });
}
Expand Down
4 changes: 2 additions & 2 deletions libs/convex_hull/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ pub fn caliper(a: &[[i64; 2]]) -> (i64, [[i64; 2]; 2]) {
} else {
let n = a.len();
let mut d = 0;
let mut ans_i = std::usize::MAX;
let mut ans_j = std::usize::MAX;
let mut ans_i = usize::MAX;
let mut ans_j = usize::MAX;
let min_position = (0..n).min_by_key(|&i| a[i][0]).unwrap();
let max_position = (0..n).max_by_key(|&i| a[i][0]).unwrap();
let start_i = min_position.min(max_position);
Expand Down
10 changes: 5 additions & 5 deletions libs/dijkstra_radix_heap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#[deprecated]
/// 一点からの距離配列を作ります。
pub fn calc_dist(s: usize, g: &[Vec<(usize, u32)>]) -> Vec<u32> {
let mut dist = vec![std::u32::MAX; g.len()];
let mut dist = vec![u32::MAX; g.len()];
dist[s] = 0;
let mut heap = radix_heap::RadixHeap::new();
heap.push(0, s);
Expand All @@ -24,8 +24,8 @@ pub fn calc_dist(s: usize, g: &[Vec<(usize, u32)>]) -> Vec<u32> {

/// 一点からの距離配列を作ります。
pub fn calc_dist_restore(s: usize, g: &[Vec<(usize, u32)>]) -> (Vec<u32>, Vec<usize>) {
let mut dist = vec![std::u32::MAX; g.len()];
let mut prv = vec![std::usize::MAX; g.len()];
let mut dist = vec![u32::MAX; g.len()];
let mut prv = vec![usize::MAX; g.len()];
prv[s] = s;
dist[s] = 0;
let mut heap = radix_heap::RadixHeap::new();
Expand Down Expand Up @@ -103,8 +103,8 @@ mod tests {
prv.iter().copied().enumerate().for_each(|(x, p)| {
let expected = if x == p {
0
} else if p == std::usize::MAX {
std::u32::MAX
} else if p == usize::MAX {
u32::MAX
} else {
dist[p] + edges.get(&(p, x)).unwrap()
};
Expand Down
8 changes: 4 additions & 4 deletions libs/dinic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -742,20 +742,20 @@ where

loop {
// calculate labels
let mut label = vec![std::u32::MAX; res.len()];
let mut label = vec![u32::MAX; res.len()];
label[s] = 0;
let mut queue = VecDeque::from(vec![s]);
while let Some(from) = queue.pop_front() {
for &__ResidualEdge { to, cap, .. } in &res[from] {
if cap == T::zero() || label[to] != std::u32::MAX {
if cap == T::zero() || label[to] != u32::MAX {
continue;
}
label[to] = label[from] + 1;
queue.push_back(to);
}
}

if label[t] == std::u32::MAX {
if label[t] == u32::MAX {
// saturated
return flow;
}
Expand Down Expand Up @@ -818,7 +818,7 @@ macro_rules! impl_value {
0
}
fn infinity() -> Self {
std::$T::MAX
$T::MAX
}
}
)*}
Expand Down
3 changes: 1 addition & 2 deletions libs/erato/src/lpd_sieve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ use super::SieveBase;
/// The complexity of algorithms are like this, but it takes extra time to grow itself implicitly.
///
/// - Construction: O ( n lg n )
/// - Prime factorization: O ( ω( n ) ), where ω( n ) is the number of prime divisors, with
/// multiple divisors counted repeatedly.
/// - Prime factorization: O ( ω( n ) ), where ω( n ) is the number of prime divisors, with multiple divisors counted repeatedly.
#[derive(Default, Debug, Clone, PartialEq)]
pub struct LpdSieve {
base: SieveBase<sieve_kind::Usize>,
Expand Down
3 changes: 1 addition & 2 deletions libs/erato/src/sieve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ use super::SieveBase;
/// The complexity of algorithms are like this, but it takes extra time to grow itself implicitly.
///
/// - Construction: Θ ( n / lg lg n )
/// - Prime factorization: Θ ( π ( √n ) ), where π ( n ) is the number of prime numbers less than
/// n.
/// - Prime factorization: Θ ( π ( √n ) ), where π ( n ) is the number of prime numbers less than n.
#[derive(Default, Debug, Clone, PartialEq)]
pub struct Sieve {
base: SieveBase<sieve_kind::Boolean>,
Expand Down
16 changes: 8 additions & 8 deletions libs/erato/src/sieve_kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ pub fn construct_is_prime_table(n: usize) -> Vec<bool> {
}

fn construct_lpd_table(n: usize) -> Vec<usize> {
let mut lpd = vec![std::usize::MAX; n];
let mut lpd = vec![usize::MAX; n];
for p in 2..n {
if lpd[p] != std::usize::MAX {
if lpd[p] != usize::MAX {
continue;
}
lpd[p] = p;
let mut i = p * p;
while i < n {
if lpd[i] == std::usize::MAX {
if lpd[i] == usize::MAX {
lpd[i] = p;
}
i += p;
Expand All @@ -93,11 +93,11 @@ mod tests {
}

#[test_case(0 => Vec::<usize>::new())]
#[test_case(1 => vec![std::usize::MAX])]
#[test_case(2 => vec![std::usize::MAX, std::usize::MAX])]
#[test_case(3 => vec![std::usize::MAX, std::usize::MAX, 2])]
#[test_case(4 => vec![std::usize::MAX, std::usize::MAX, 2, 3])]
#[test_case(5 => vec![std::usize::MAX, std::usize::MAX, 2, 3, 2])]
#[test_case(1 => vec![usize::MAX])]
#[test_case(2 => vec![usize::MAX, usize::MAX])]
#[test_case(3 => vec![usize::MAX, usize::MAX, 2])]
#[test_case(4 => vec![usize::MAX, usize::MAX, 2, 3])]
#[test_case(5 => vec![usize::MAX, usize::MAX, 2, 3, 2])]
fn test_construct_lpd_table(n: usize) -> Vec<usize> {
construct_lpd_table(n)
}
Expand Down
2 changes: 2 additions & 0 deletions libs/fp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ macro_rules! impl_from_signed {
($($t:ty),*) => {
$(
impl<const P: u64> From<$t> for Fp<P> {
#[allow(clippy::cast_lossless)]
fn from(x: $t) -> Self {
if x < 0 {
-Self::new((P as i64 - x as i64) as u64)
Expand All @@ -258,6 +259,7 @@ macro_rules! impl_from_unsigned {
($($t:ty),*) => {
$(
impl<const P: u64> From<$t> for Fp<P> {
#[allow(clippy::cast_lossless)]
fn from(x: $t) -> Self { Self::new(x as u64) }
}
)*
Expand Down
Loading
Loading