Skip to content

Commit

Permalink
Minor code style improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
cyqsimon committed Oct 17, 2023
1 parent bc604df commit 3e2e652
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/tests/cases/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,27 @@ use crate::{
};

pub fn sleep_and_quit_events(sleep_num: usize) -> Box<TerminalEvents> {
let mut events: Vec<Option<Event>> = iter::repeat(None).take(sleep_num).collect();
events.push(Some(Event::Key(KeyEvent::new(
KeyCode::Char('c'),
KeyModifiers::CONTROL,
))));
let events = iter::repeat(None)
.take(sleep_num)
.chain([Some(Event::Key(KeyEvent::new(
KeyCode::Char('c'),
KeyModifiers::CONTROL,
)))])
.collect();
Box::new(TerminalEvents::new(events))
}

pub fn sleep_resize_and_quit_events(sleep_num: usize) -> Box<TerminalEvents> {
let mut events: Vec<Option<Event>> = iter::repeat(None).take(sleep_num).collect();
events.push(Some(Event::Resize(100, 100)));
events.push(Some(Event::Key(KeyEvent::new(
KeyCode::Char('c'),
KeyModifiers::CONTROL,
))));
let events = iter::repeat(None)
.take(sleep_num)
.chain([
Some(Event::Resize(100, 100)),
Some(Event::Key(KeyEvent::new(
KeyCode::Char('c'),
KeyModifiers::CONTROL,
))),
])
.collect();
Box::new(TerminalEvents::new(events))
}

Expand Down

0 comments on commit 3e2e652

Please sign in to comment.