Skip to content

Commit

Permalink
get rid of a warning - it's ok to unwrap() here
Browse files Browse the repository at this point in the history
and we unwrap() to panic on any new Err returned
from a future ncurses implementation change.

newterm https://github.com/jeaye/ncurses-rs/blob/3aa22bc279e4929e3ab69d49f75a18eda3e431e9/src/lib.rs#L1023-L1029
CString::new https://doc.rust-lang.org/std/ffi/struct.CString.html#method.new
  • Loading branch information
correabuscar committed May 25, 2024
1 parent cd5b151 commit 1b633da
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cursive/src/backends/curses/n.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,12 @@ impl Backend {
let path = CString::new(output_path).unwrap();
unsafe { libc::fopen(path.as_ptr(), mode.as_ptr()) }
};
ncurses::newterm(None, output, input);
let _ = ncurses::newterm(None, output, input).unwrap();
// unwrap() is guaranteed not* to panic here ^ unless the underlaying
// ncurses-rs implementation changes API in the future and returns Err
// for other reasons as well, which we do want to catch/panic due to.
// *because no string is being passed as the first arg. to newterm

// Enable keypad (like arrows)
ncurses::keypad(ncurses::stdscr(), true);

Expand Down

0 comments on commit 1b633da

Please sign in to comment.