Skip to content

Commit 1d2ea75

Browse files
author
Matt Wilkinson
committed
rename IsAtty to IsTerminal
1 parent f9f2c8f commit 1d2ea75

File tree

8 files changed

+77
-65
lines changed

8 files changed

+77
-65
lines changed

library/std/src/io/mod.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,8 @@ pub use self::error::{Error, ErrorKind, Result};
273273
#[unstable(feature = "internal_output_capture", issue = "none")]
274274
#[doc(no_inline, hidden)]
275275
pub use self::stdio::set_output_capture;
276-
#[unstable(feature = "is_atty", issue = "80937")]
277-
pub use self::stdio::IsAtty;
276+
#[unstable(feature = "is_terminal", issue = "80937")]
277+
pub use self::stdio::IsTerminal;
278278
#[stable(feature = "rust1", since = "1.0.0")]
279279
pub use self::stdio::{stderr, stdin, stdout, Stderr, Stdin, Stdout};
280280
#[stable(feature = "rust1", since = "1.0.0")]
@@ -2224,7 +2224,11 @@ impl<T: Read, U: Read> Read for Chain<T, U> {
22242224

22252225
unsafe fn initializer(&self) -> Initializer {
22262226
let initializer = self.first.initializer();
2227-
if initializer.should_initialize() { initializer } else { self.second.initializer() }
2227+
if initializer.should_initialize() {
2228+
initializer
2229+
} else {
2230+
self.second.initializer()
2231+
}
22282232
}
22292233
}
22302234

@@ -2243,7 +2247,11 @@ impl<T: BufRead, U: BufRead> BufRead for Chain<T, U> {
22432247
}
22442248

22452249
fn consume(&mut self, amt: usize) {
2246-
if !self.done_first { self.first.consume(amt) } else { self.second.consume(amt) }
2250+
if !self.done_first {
2251+
self.first.consume(amt)
2252+
} else {
2253+
self.second.consume(amt)
2254+
}
22472255
}
22482256
}
22492257

library/std/src/io/stdio.rs

+27-27
Original file line numberDiff line numberDiff line change
@@ -966,54 +966,54 @@ pub fn _eprint(args: fmt::Arguments<'_>) {
966966
#[cfg(test)]
967967
pub use realstd::io::{_eprint, _print};
968968

969-
/// Trait to determine if stdio stream (Stdin, Stdout, Stderr) is a tty.
970-
#[unstable(feature = "is_atty", issue = "80937")]
971-
pub trait IsAtty {
972-
/// returns true if implemented stream is a tty.
973-
fn is_atty() -> bool;
969+
/// Trait to determine if stdio stream (Stdin, Stdout, Stderr) is a terminal/tty.
970+
#[unstable(feature = "is_terminal", issue = "80937")]
971+
pub trait IsTerminal {
972+
/// returns true if stdio stream (Stdin, Stdout, Stderr) is a terminal/tty.
973+
fn is_terminal() -> bool;
974974
}
975975

976-
#[unstable(feature = "is_atty", issue = "80937")]
976+
#[unstable(feature = "is_terminal", issue = "80937")]
977977
cfg_if::cfg_if! {
978978
if #[cfg(any(unix, windows, hermit))] {
979-
#[unstable(feature = "is_atty", issue = "80937")]
980-
impl IsAtty for Stdin {
981-
fn is_atty() -> bool {
982-
stdio::Stdin::is_atty()
979+
#[unstable(feature = "is_terminal", issue = "80937")]
980+
impl IsTerminal for Stdin {
981+
fn is_terminal() -> bool {
982+
stdio::Stdin::is_terminal()
983983
}
984984
}
985985

986-
#[unstable(feature = "is_atty", issue = "80937")]
987-
impl IsAtty for Stdout {
988-
fn is_atty() -> bool {
989-
stdio::Stdout::is_atty()
986+
#[unstable(feature = "is_terminal", issue = "80937")]
987+
impl IsTerminal for Stdout {
988+
fn is_terminal() -> bool {
989+
stdio::Stdout::is_terminal()
990990
}
991991
}
992992

993-
#[unstable(feature = "is_atty", issue = "80937")]
994-
impl IsAtty for Stderr {
995-
fn is_atty() -> bool {
996-
stdio::Stderr::is_atty()
993+
#[unstable(feature = "is_terminal", issue = "80937")]
994+
impl IsTerminal for Stderr {
995+
fn is_terminal() -> bool {
996+
stdio::Stderr::is_terminal()
997997
}
998998
}
999999
} else {
1000-
#[unstable(feature = "is_atty", issue = "80937")]
1001-
impl IsAtty for Stdin {
1002-
fn is_atty() -> bool {
1000+
#[unstable(feature = "is_terminal", issue = "80937")]
1001+
impl IsTerminal for Stdin {
1002+
fn is_terminal() -> bool {
10031003
false
10041004
}
10051005
}
10061006

1007-
#[unstable(feature = "is_atty", issue = "80937")]
1008-
impl IsAtty for Stdout {
1009-
fn is_atty() -> bool {
1007+
#[unstable(feature = "is_terminal", issue = "80937")]
1008+
impl IsTerminal for Stdout {
1009+
fn is_terminal() -> bool {
10101010
false
10111011
}
10121012
}
10131013

1014-
#[unstable(feature = "is_atty", issue = "80937")]
1015-
impl IsAtty for Stderr {
1016-
fn is_atty() -> bool {
1014+
#[unstable(feature = "is_terminal", issue = "80937")]
1015+
impl IsTerminal for Stderr {
1016+
fn is_terminal() -> bool {
10171017
false
10181018
}
10191019
}

library/std/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@
335335
#![feature(unwind_attributes)]
336336
#![feature(vec_into_raw_parts)]
337337
#![feature(vec_spare_capacity)]
338-
#![feature(is_atty)]
338+
#![feature(is_terminal)]
339339
// NB: the above list is sorted to minimize merge conflicts.
340340
#![default_lib_allocator]
341341

library/std/src/sys/hermit/ext/io.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@ use crate::io;
22
use crate::sys;
33
use crate::sys::hermit::abi;
44

5-
#[unstable(feature = "is_atty", issue = "80937")]
6-
impl io::IsAtty for sys::stdio::Stdin {
7-
fn is_atty() -> bool {
5+
#[unstable(feature = "is_terminal", issue = "80937")]
6+
impl io::IsTerminal for sys::stdio::Stdin {
7+
fn is_terminal() -> bool {
88
abi::isatty(abi::STDIN_FILENO)
99
}
1010
}
1111

12-
#[unstable(feature = "is_atty", issue = "80937")]
13-
impl io::IsAtty for sys::stdio::Stdout {
14-
fn is_atty() -> bool {
12+
#[unstable(feature = "is_terminal", issue = "80937")]
13+
impl io::IsTerminal for sys::stdio::Stdout {
14+
fn is_terminal() -> bool {
1515
abi::isatty(abi::STDOUT_FILENO)
1616
}
1717
}
18-
#[unstable(feature = "is_atty", issue = "80937")]
19-
impl io::IsAtty for sys::stdio::Stderr {
20-
fn is_atty() -> bool {
18+
#[unstable(feature = "is_terminal", issue = "80937")]
19+
impl io::IsTerminal for sys::stdio::Stderr {
20+
fn is_terminal() -> bool {
2121
abi::isatty(abi::STDERR_FILENO)
2222
}
2323
}

library/std/src/sys/unix/ext/io.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -182,22 +182,22 @@ impl<'a> AsRawFd for io::StderrLock<'a> {
182182
}
183183
}
184184

185-
#[unstable(feature = "is_atty", issue = "80937")]
186-
impl io::IsAtty for sys::stdio::Stdin {
187-
fn is_atty() -> bool {
185+
#[unstable(feature = "is_terminal", issue = "80937")]
186+
impl io::IsTerminal for sys::stdio::Stdin {
187+
fn is_terminal() -> bool {
188188
unsafe { libc::isatty(libc::STDIN_FILENO) != 0 }
189189
}
190190
}
191191

192-
#[unstable(feature = "is_atty", issue = "80937")]
193-
impl io::IsAtty for sys::stdio::Stdout {
194-
fn is_atty() -> bool {
192+
#[unstable(feature = "is_terminal", issue = "80937")]
193+
impl io::IsTerminal for sys::stdio::Stdout {
194+
fn is_terminal() -> bool {
195195
unsafe { libc::isatty(libc::STDOUT_FILENO) != 0 }
196196
}
197197
}
198-
#[unstable(feature = "is_atty", issue = "80937")]
199-
impl io::IsAtty for sys::stdio::Stderr {
200-
fn is_atty() -> bool {
198+
#[unstable(feature = "is_terminal", issue = "80937")]
199+
impl io::IsTerminal for sys::stdio::Stderr {
200+
fn is_terminal() -> bool {
201201
unsafe { libc::isatty(libc::STDERR_FILENO) != 0 }
202202
}
203203
}

library/std/src/sys/windows/ext/io.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,9 @@ impl IntoRawSocket for net::UdpSocket {
221221
}
222222
}
223223

224-
#[unstable(feature = "is_atty", issue = "80937")]
225-
impl io::IsAtty for sys::stdio::Stdin {
226-
fn is_atty() -> bool {
224+
#[unstable(feature = "is_terminal", issue = "80937")]
225+
impl io::IsTerminal for sys::stdio::Stdin {
226+
fn is_terminal() -> bool {
227227
use c::{
228228
STD_ERROR_HANDLE as STD_ERROR, STD_INPUT_HANDLE as STD_INPUT,
229229
STD_OUTPUT_HANDLE as STD_OUTPUT,
@@ -252,9 +252,9 @@ impl io::IsAtty for sys::stdio::Stdin {
252252
}
253253
}
254254

255-
#[unstable(feature = "is_atty", issue = "80937")]
256-
impl io::IsAtty for sys::stdio::Stdout {
257-
fn is_atty() -> bool {
255+
#[unstable(feature = "is_terminal", issue = "80937")]
256+
impl io::IsTerminal for sys::stdio::Stdout {
257+
fn is_terminal() -> bool {
258258
use c::{
259259
STD_ERROR_HANDLE as STD_ERROR, STD_INPUT_HANDLE as STD_INPUT,
260260
STD_OUTPUT_HANDLE as STD_OUTPUT,
@@ -283,9 +283,9 @@ impl io::IsAtty for sys::stdio::Stdout {
283283
}
284284
}
285285

286-
#[unstable(feature = "is_atty", issue = "80937")]
287-
impl io::IsAtty for sys::stdio::Stderr {
288-
fn is_atty() -> bool {
286+
#[unstable(feature = "is_terminal", issue = "80937")]
287+
impl io::IsTerminal for sys::stdio::Stderr {
288+
fn is_terminal() -> bool {
289289
use c::{
290290
STD_ERROR_HANDLE as STD_ERROR, STD_INPUT_HANDLE as STD_INPUT,
291291
STD_OUTPUT_HANDLE as STD_OUTPUT,
@@ -314,7 +314,7 @@ impl io::IsAtty for sys::stdio::Stderr {
314314
}
315315
}
316316

317-
#[unstable(feature = "is_atty", issue = "80937")]
317+
#[unstable(feature = "is_terminal", issue = "80937")]
318318
unsafe fn console_on_any(fds: &[c::DWORD]) -> bool {
319319
use c::{GetConsoleMode, GetStdHandle};
320320

@@ -327,7 +327,7 @@ unsafe fn console_on_any(fds: &[c::DWORD]) -> bool {
327327
}
328328
false
329329
}
330-
#[unstable(feature = "is_atty", issue = "80937")]
330+
#[unstable(feature = "is_terminal", issue = "80937")]
331331
unsafe fn msys_tty_on(fd: c::DWORD) -> bool {
332332
use std::{mem, slice};
333333

library/test/src/cli.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Module converting command-line arguments into test configuration.
22
33
use std::env;
4-
use std::io::{IsAtty, Stdout};
4+
use std::io::{IsTerminal, Stdout};
55
use std::path::PathBuf;
66

77
use super::options::{ColorConfig, Options, OutputFormat, RunIgnored};
@@ -30,7 +30,7 @@ pub struct TestOpts {
3030
impl TestOpts {
3131
pub fn use_color(&self) -> bool {
3232
match self.color {
33-
ColorConfig::AutoColor => !self.nocapture && Stdout::is_atty(),
33+
ColorConfig::AutoColor => !self.nocapture && Stdout::is_terminal(),
3434
ColorConfig::AlwaysColor => true,
3535
ColorConfig::NeverColor => false,
3636
}

library/test/src/lib.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#![feature(termination_trait_lib)]
3131
#![feature(test)]
3232
#![feature(total_cmp)]
33-
#![feature(is_atty)]
33+
#![feature(is_terminal)]
3434

3535
// Public reexports
3636
pub use self::bench::{black_box, Bencher};
@@ -292,7 +292,11 @@ where
292292
fn calc_timeout(timeout_queue: &VecDeque<TimeoutEntry>) -> Option<Duration> {
293293
timeout_queue.front().map(|&TimeoutEntry { timeout: next_timeout, .. }| {
294294
let now = Instant::now();
295-
if next_timeout >= now { next_timeout - now } else { Duration::new(0, 0) }
295+
if next_timeout >= now {
296+
next_timeout - now
297+
} else {
298+
Duration::new(0, 0)
299+
}
296300
})
297301
}
298302

0 commit comments

Comments
 (0)