Skip to content

Commit 6198cf1

Browse files
committed
Rust 2021 edition
1 parent 1883501 commit 6198cf1

File tree

5 files changed

+9
-11
lines changed

5 files changed

+9
-11
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: rust
22
rust:
3-
- 1.51.0 # Version currently supported by Codeforces
3+
#- 1.58.0 # Version currently supported by Codeforces
44
- stable
55
- beta
66
- nightly
@@ -12,5 +12,4 @@ script:
1212
matrix:
1313
allow_failures:
1414
- rust: nightly
15-
- rust: beta # clippy currently has a bug on beta
1615
fast_finish: true

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[package]
22
name = "contest-algorithms"
3-
version = "0.3.0"
3+
version = "0.3.1-alpha.0"
44
authors = ["Aram Ebtekar"]
5-
edition = "2018"
5+
edition = "2021"
66

77
description = "Common algorithms and data structures for programming contests"
88
repository = "https://github.com/EbTech/rust-algorithms"

src/graph/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl<'a> Iterator for DfsIterator<'a> {
9191
fn next(&mut self) -> Option<Self::Item> {
9292
loop {
9393
let &u = self.stack.last()?;
94-
while let Some((e, v)) = self.adj_iters[u].next() {
94+
for (e, v) in self.adj_iters[u].by_ref() {
9595
if !self.visited[v] {
9696
self.visited[v] = true;
9797
self.stack.push(v);

src/scanner.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ impl<R: io::BufRead> Scanner<R> {
3535
}
3636

3737
/// Same API as Scanner but nearly twice as fast, using horribly unsafe dark arts
38-
/// **REQUIRES** Rust 1.34 or higher
3938
pub struct UnsafeScanner<R> {
4039
reader: R,
4140
buf_str: Vec<u8>,
@@ -118,9 +117,8 @@ mod test {
118117

119118
#[test]
120119
fn test_compile_stdio() {
121-
let (stdin, stdout) = (io::stdin(), io::stdout());
122-
let mut scan = Scanner::new(stdin.lock());
123-
let mut out = io::BufWriter::new(stdout.lock());
120+
let mut scan = Scanner::new(io::stdin().lock());
121+
let mut out = io::BufWriter::new(io::stdout().lock());
124122

125123
if false {
126124
solve(&mut scan, &mut out);

src/string_proc.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ impl<C: std::hash::Hash + Eq> MultiMatcher<C> {
142142
/// If there are duplicate patterns, all but one copy will be ignored.
143143
pub fn new(patterns: impl IntoIterator<Item = impl IntoIterator<Item = C>>) -> Self {
144144
let mut trie = Trie::default();
145+
#[allow(clippy::needless_collect)] // It's not needless: it affects trie.links.len()
145146
let pat_nodes: Vec<usize> = patterns.into_iter().map(|pat| trie.insert(pat)).collect();
146147

147148
let mut pat_id = vec![None; trie.links.len()];
@@ -155,7 +156,7 @@ impl<C: std::hash::Hash + Eq> MultiMatcher<C> {
155156

156157
while let Some(node) = q.pop_front() {
157158
for (ch, &child) in &trie.links[node] {
158-
let nx = Self::next(&trie, &fail, fail[node], &ch);
159+
let nx = Self::next(&trie, &fail, fail[node], ch);
159160
fail[child] = nx;
160161
fast[child] = if pat_id[nx].is_some() { nx } else { fast[nx] };
161162
q.push_back(child);
@@ -246,7 +247,7 @@ impl SuffixArray {
246247
let mut cur_rank = prev_rank.clone();
247248

248249
let pos = (n - skip..n).chain(sfx.into_iter().filter_map(|p| p.checked_sub(skip)));
249-
sfx = Self::counting_sort(pos, &prev_rank, max(n, 256));
250+
sfx = Self::counting_sort(pos, prev_rank, max(n, 256));
250251

251252
let mut prev = sfx[0];
252253
cur_rank[prev] = 0;

0 commit comments

Comments
 (0)