diff --git a/Cargo.toml b/Cargo.toml index 65fd38eab..8ba4f4b70 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ keywords = ["tab", "table", "format", "pretty", "print"] categories = ["command-line-interface"] license = "BSD-3-Clause" edition = "2018" +rust-version = "1.56.1" exclude = [ "prettytable-evcxr.png" ] @@ -23,6 +24,7 @@ codecov = { repository = "phsym/prettytable-rs", branch = "master", service = "g maintenance = { status = "passively-maintained" } [features] +# TODO: use `dep:` syntax here and below once MSRV is at least `1.60` default = ["win_crlf", "csv"] evcxr = [] win_crlf = [] @@ -39,6 +41,9 @@ name = "prettytable" unicode-width = "0.1" term = "0.7" lazy_static = "1.4" -is-terminal = "0.4" encode_unicode = "1.0" csv = { version = "1.1", optional = true } + +# TODO: remove it once MSRV is at least `1.70` +[target.'cfg(not(prettytable_is_terminal_implementation = "std"))'.dependencies] +is-terminal = "0.4" diff --git a/src/lib.rs b/src/lib.rs index e4fdb78d4..c34332400 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -194,7 +194,11 @@ impl<'a> TableSlice<'a> { /// # Returns /// A `Result` holding the number of lines printed, or an `io::Error` if any failure happens pub fn print_tty(&self, force_colorize: bool) -> Result { + #[cfg(prettytable_is_terminal_implementation = "std")] + use std::io::IsTerminal; + #[cfg(not(prettytable_is_terminal_implementation = "std"))] use is_terminal::IsTerminal; + match (stdout(), io::stdout().is_terminal() || force_colorize) { (Some(mut o), true) => self.print_term(&mut *o), _ => self.print(&mut io::stdout()),