Skip to content

Commit

Permalink
Merge pull request #36 from sunfishcode/main
Browse files Browse the repository at this point in the history
Optimize away a call to `std::io::stdout()`.
  • Loading branch information
eminence committed Jul 4, 2022
2 parents 365bbe9 + a522cfe commit 8e46aea
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ edition = "2018"


[target.'cfg(not(windows))'.dependencies]
rustix = { version = "0.35.6", features = ["termios"] }
rustix = { version = "0.35.7", features = ["termios"] }

[target.'cfg(windows)'.dependencies.windows-sys]
version = "0.36.0"
Expand Down
4 changes: 2 additions & 2 deletions src/unix.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use super::{Height, Width};
use std::os::unix::io::RawFd;
use rustix::fd::{BorrowedFd, AsRawFd};
use rustix::fd::BorrowedFd;

/// Returns the size of the terminal defaulting to STDOUT, if available.
///
/// If STDOUT is not a tty, returns `None`
pub fn terminal_size() -> Option<(Width, Height)> {
terminal_size_using_fd(std::io::stdout().as_raw_fd())
terminal_size_using_fd(rustix::io::raw_stdout())
}

/// Returns the size of the terminal using the given file descriptor, if available.
Expand Down

0 comments on commit 8e46aea

Please sign in to comment.