use array_windows instead of windows in the compiler

This commit is contained in:
Bastian Kauschke 2020-09-17 09:28:14 +02:00
parent 255a4c58f5
commit 3435683fd5
11 changed files with 21 additions and 17 deletions

View file

@ -5,6 +5,7 @@
//! This API is completely unstable and subject to change.
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
#![feature(array_windows)]
#![feature(crate_visibility_modifier)]
#![feature(const_fn)]
#![feature(const_panic)]
@ -1158,7 +1159,12 @@ impl<S: Encoder> Encodable<S> for SourceFile {
let max_line_length = if lines.len() == 1 {
0
} else {
lines.windows(2).map(|w| w[1] - w[0]).map(|bp| bp.to_usize()).max().unwrap()
lines
.array_windows()
.map(|&[fst, snd]| snd - fst)
.map(|bp| bp.to_usize())
.max()
.unwrap()
};
let bytes_per_diff: u8 = match max_line_length {
@ -1173,7 +1179,7 @@ impl<S: Encoder> Encodable<S> for SourceFile {
// Encode the first element.
lines[0].encode(s)?;
let diff_iter = (&lines[..]).windows(2).map(|w| (w[1] - w[0]));
let diff_iter = lines[..].array_windows().map(|&[fst, snd]| snd - fst);
match bytes_per_diff {
1 => {