Skip to content

Commit

Permalink
Make drop impl of OutputType more prominent
Browse files Browse the repository at this point in the history
  • Loading branch information
th1000s committed Jul 22, 2024
1 parent 76961fa commit 14fe71a
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/utils/bat/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ pub enum OutputType {
Stdout(io::Stdout),
}

impl Drop for OutputType {
fn drop(&mut self) {
if let OutputType::Pager(ref mut command) = *self {
let _ = command.wait();
}
}
}

impl OutputType {
/// Create a pager and write all data into it. Waits until the pager exits.
/// The expectation is that the program will exit afterwards.
Expand Down Expand Up @@ -241,11 +249,3 @@ delta is not an appropriate value for $PAGER \
None
}
}

impl Drop for OutputType {
fn drop(&mut self) {
if let OutputType::Pager(ref mut command) = *self {
let _ = command.wait();
}
}
}

0 comments on commit 14fe71a

Please sign in to comment.