cleaned up all compiler warnings
This commit is contained in:
@@ -3,35 +3,6 @@ use std::sync::LazyLock;
|
||||
use termios::{LocalFlags, Termios};
|
||||
|
||||
use crate::prelude::*;
|
||||
///
|
||||
/// The previous state of the terminal options.
|
||||
///
|
||||
/// This variable stores the terminal settings at the start of the program and
|
||||
/// restores them when the program exits. It is initialized exactly once at the
|
||||
/// start of the program and accessed exactly once at the end of the program. It
|
||||
/// will not be mutated or accessed under any other circumstances.
|
||||
///
|
||||
/// This ended up being necessary because wrapping Termios in a thread-safe way
|
||||
/// was unreasonably tricky.
|
||||
///
|
||||
/// The possible states of this variable are:
|
||||
/// - `None`: The terminal options have not been set yet (before
|
||||
/// initialization).
|
||||
/// - `Some(None)`: There were no terminal options to save (i.e., no terminal
|
||||
/// input detected).
|
||||
/// - `Some(Some(Termios))`: The terminal options (as `Termios`) have been
|
||||
/// saved.
|
||||
///
|
||||
/// **Important:** This static variable is mutable and accessed via unsafe code.
|
||||
/// It is only safe to use because:
|
||||
/// - It is set once during program startup and accessed once during program
|
||||
/// exit.
|
||||
/// - It is not mutated or accessed after the initial setup and final read.
|
||||
///
|
||||
/// **Caution:** Future changes to this code should respect these constraints to
|
||||
/// ensure safety. Modifying or accessing this variable outside the defined
|
||||
/// lifecycle could lead to undefined behavior.
|
||||
pub(crate) static mut SAVED_TERMIOS: Option<Option<Termios>> = None;
|
||||
|
||||
pub static TTY_FILENO: LazyLock<RawFd> = LazyLock::new(|| {
|
||||
open("/dev/tty", OFlag::O_RDWR, Mode::empty()).expect("Failed to open /dev/tty")
|
||||
|
||||
Reference in New Issue
Block a user