Skip to content

Commit

Permalink
use std::mem::swap
Browse files Browse the repository at this point in the history
  • Loading branch information
bergey committed Dec 28, 2022
1 parent 22b783d commit 41e2f92
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ where R: Iterator<Item = io::Result<String>> {
D => {
if let Some(ix) = read.find('\n') {
write.push_str(&read[ix+1..]);
let tmp = read;
read = write;
write = tmp;
std::mem::swap(&mut read, &mut write);
write.clear();
} else {
read.clear();
Expand Down Expand Up @@ -109,17 +107,11 @@ where R: Iterator<Item = io::Result<String>> {
// TODO greedy match
let changed = regex::replace(&regex, &read, &mut write, replacement);
if changed {
let tmp = read;
read = write;
write = tmp;
std::mem::swap(&mut read, &mut write);
write.clear();
}
},
Fx => {
let tmp = read;
read = hold;
hold = tmp;
}
Fx => std::mem::swap(&mut read, &mut hold),
}

}
Expand Down

0 comments on commit 41e2f92

Please sign in to comment.