Closed
Description
This code snippet causes rustc to panic:
fn trim_lines(text: &str) -> impl Iterator<Item=&str> {
let mut prefix_length = 0;
for c in text.chars() {
match c {
' ' => prefix_length += 1,
'\n' => continue,
_ => break,
}
}
text.lines().map(|line| {
if line.len() >= prefix_length {
&line[prefix_length..]
} else {
line
}
})
}
fn main() {
trim_lines("hello");
}
Meta
rustc 1.23.0-nightly (33374fa 2017-11-20)
binary: rustc
commit-hash: 33374fa
commit-date: 2017-11-20
host: x86_64-unknown-linux-gnu
release: 1.23.0-nightly
LLVM version: 4.0
The same thing happens with 1.24 nightly too on rust playground.
Metadata
Metadata
Assignees
Labels
No labels