Skip to content

Commit 383fcce

Browse files
tamirddjc
authored andcommitted
Add #![warn(unreachable_pub)] and appease
1 parent b892409 commit 383fcce

File tree

5 files changed

+30
-28
lines changed

5 files changed

+30
-28
lines changed

src/ansi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ struct Match<'a> {
125125

126126
impl<'a> Match<'a> {
127127
#[inline]
128-
pub fn as_str(&self) -> &'a str {
128+
pub(crate) fn as_str(&self) -> &'a str {
129129
&self.text[self.start..self.end]
130130
}
131131
}

src/common_term.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,30 @@ use std::io;
22

33
use crate::term::Term;
44

5-
pub fn move_cursor_down(out: &Term, n: usize) -> io::Result<()> {
5+
pub(crate) fn move_cursor_down(out: &Term, n: usize) -> io::Result<()> {
66
if n > 0 {
77
out.write_str(&format!("\x1b[{}B", n))
88
} else {
99
Ok(())
1010
}
1111
}
1212

13-
pub fn move_cursor_up(out: &Term, n: usize) -> io::Result<()> {
13+
pub(crate) fn move_cursor_up(out: &Term, n: usize) -> io::Result<()> {
1414
if n > 0 {
1515
out.write_str(&format!("\x1b[{}A", n))
1616
} else {
1717
Ok(())
1818
}
1919
}
20-
pub fn move_cursor_left(out: &Term, n: usize) -> io::Result<()> {
20+
pub(crate) fn move_cursor_left(out: &Term, n: usize) -> io::Result<()> {
2121
if n > 0 {
2222
out.write_str(&format!("\x1b[{}D", n))
2323
} else {
2424
Ok(())
2525
}
2626
}
2727

28-
pub fn move_cursor_right(out: &Term, n: usize) -> io::Result<()> {
28+
pub(crate) fn move_cursor_right(out: &Term, n: usize) -> io::Result<()> {
2929
if n > 0 {
3030
out.write_str(&format!("\x1b[{}C", n))
3131
} else {
@@ -34,11 +34,11 @@ pub fn move_cursor_right(out: &Term, n: usize) -> io::Result<()> {
3434
}
3535

3636
#[inline]
37-
pub fn move_cursor_to(out: &Term, x: usize, y: usize) -> io::Result<()> {
37+
pub(crate) fn move_cursor_to(out: &Term, x: usize, y: usize) -> io::Result<()> {
3838
out.write_str(&format!("\x1B[{};{}H", y + 1, x + 1))
3939
}
4040

41-
pub fn clear_chars(out: &Term, n: usize) -> io::Result<()> {
41+
pub(crate) fn clear_chars(out: &Term, n: usize) -> io::Result<()> {
4242
if n > 0 {
4343
out.write_str(&format!("\x1b[{}D\x1b[0K", n))
4444
} else {
@@ -47,26 +47,26 @@ pub fn clear_chars(out: &Term, n: usize) -> io::Result<()> {
4747
}
4848

4949
#[inline]
50-
pub fn clear_line(out: &Term) -> io::Result<()> {
50+
pub(crate) fn clear_line(out: &Term) -> io::Result<()> {
5151
out.write_str("\r\x1b[2K")
5252
}
5353

5454
#[inline]
55-
pub fn clear_screen(out: &Term) -> io::Result<()> {
55+
pub(crate) fn clear_screen(out: &Term) -> io::Result<()> {
5656
out.write_str("\r\x1b[2J\r\x1b[H")
5757
}
5858

5959
#[inline]
60-
pub fn clear_to_end_of_screen(out: &Term) -> io::Result<()> {
60+
pub(crate) fn clear_to_end_of_screen(out: &Term) -> io::Result<()> {
6161
out.write_str("\r\x1b[0J")
6262
}
6363

6464
#[inline]
65-
pub fn show_cursor(out: &Term) -> io::Result<()> {
65+
pub(crate) fn show_cursor(out: &Term) -> io::Result<()> {
6666
out.write_str("\x1b[?25h")
6767
}
6868

6969
#[inline]
70-
pub fn hide_cursor(out: &Term) -> io::Result<()> {
70+
pub(crate) fn hide_cursor(out: &Term) -> io::Result<()> {
7171
out.write_str("\x1b[?25l")
7272
}

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@
7676
//! for stripping and taking ansi escape codes into account for length
7777
//! calculations).
7878
79+
#![warn(unreachable_pub)]
80+
7981
pub use crate::kb::Key;
8082
pub use crate::term::{
8183
user_attended, user_attended_stderr, Term, TermFamily, TermFeatures, TermTarget,

src/term.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub enum TermTarget {
3838
}
3939

4040
#[derive(Debug)]
41-
pub struct TermInner {
41+
struct TermInner {
4242
target: TermTarget,
4343
buffer: Option<Mutex<Vec<u8>>>,
4444
prompt: RwLock<String>,
@@ -657,8 +657,8 @@ impl Read for &Term {
657657
}
658658

659659
#[cfg(all(unix, not(target_arch = "wasm32")))]
660-
pub use crate::unix_term::*;
660+
pub(crate) use crate::unix_term::*;
661661
#[cfg(target_arch = "wasm32")]
662-
pub use crate::wasm_term::*;
662+
pub(crate) use crate::wasm_term::*;
663663
#[cfg(windows)]
664-
pub use crate::windows_term::*;
664+
pub(crate) use crate::windows_term::*;

src/unix_term.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ use once_cell::sync::Lazy;
1313
use crate::kb::Key;
1414
use crate::term::Term;
1515

16-
pub use crate::common_term::*;
16+
pub(crate) use crate::common_term::*;
1717

18-
pub const DEFAULT_WIDTH: u16 = 80;
18+
pub(crate) const DEFAULT_WIDTH: u16 = 80;
1919

2020
#[inline]
21-
pub fn is_a_terminal(out: &Term) -> bool {
21+
pub(crate) fn is_a_terminal(out: &Term) -> bool {
2222
unsafe { libc::isatty(out.as_raw_fd()) != 0 }
2323
}
2424

25-
pub fn is_a_color_terminal(out: &Term) -> bool {
25+
pub(crate) fn is_a_color_terminal(out: &Term) -> bool {
2626
if !is_a_terminal(out) {
2727
return false;
2828
}
@@ -37,7 +37,7 @@ pub fn is_a_color_terminal(out: &Term) -> bool {
3737
}
3838
}
3939

40-
pub fn c_result<F: FnOnce() -> libc::c_int>(f: F) -> io::Result<()> {
40+
fn c_result<F: FnOnce() -> libc::c_int>(f: F) -> io::Result<()> {
4141
let res = f();
4242
if res != 0 {
4343
Err(io::Error::last_os_error())
@@ -46,7 +46,7 @@ pub fn c_result<F: FnOnce() -> libc::c_int>(f: F) -> io::Result<()> {
4646
}
4747
}
4848

49-
pub fn terminal_size(out: &Term) -> Option<(u16, u16)> {
49+
pub(crate) fn terminal_size(out: &Term) -> Option<(u16, u16)> {
5050
unsafe {
5151
if libc::isatty(out.as_raw_fd()) != 1 {
5252
return None;
@@ -66,7 +66,7 @@ pub fn terminal_size(out: &Term) -> Option<(u16, u16)> {
6666
}
6767
}
6868

69-
pub fn read_secure() -> io::Result<String> {
69+
pub(crate) fn read_secure() -> io::Result<String> {
7070
let mut f_tty;
7171
let fd = unsafe {
7272
if libc::isatty(libc::STDIN_FILENO) == 1 {
@@ -300,7 +300,7 @@ fn read_single_key_impl(fd: i32) -> Result<Key, io::Error> {
300300
}
301301
}
302302

303-
pub fn read_single_key(ctrlc_key: bool) -> io::Result<Key> {
303+
pub(crate) fn read_single_key(ctrlc_key: bool) -> io::Result<Key> {
304304
let tty_f;
305305
let fd = unsafe {
306306
if libc::isatty(libc::STDIN_FILENO) == 1 {
@@ -339,7 +339,7 @@ pub fn read_single_key(ctrlc_key: bool) -> io::Result<Key> {
339339
rv
340340
}
341341

342-
pub fn key_from_utf8(buf: &[u8]) -> Key {
342+
fn key_from_utf8(buf: &[u8]) -> Key {
343343
if let Ok(s) = str::from_utf8(buf) {
344344
if let Some(c) = s.chars().next() {
345345
return Key::Char(c);
@@ -355,15 +355,15 @@ static IS_LANG_UTF8: Lazy<bool> = Lazy::new(|| match std::env::var("LANG") {
355355
});
356356

357357
#[cfg(target_os = "macos")]
358-
pub fn wants_emoji() -> bool {
358+
pub(crate) fn wants_emoji() -> bool {
359359
true
360360
}
361361

362362
#[cfg(not(target_os = "macos"))]
363-
pub fn wants_emoji() -> bool {
363+
pub(crate) fn wants_emoji() -> bool {
364364
*IS_LANG_UTF8
365365
}
366366

367-
pub fn set_title<T: Display>(title: T) {
367+
pub(crate) fn set_title<T: Display>(title: T) {
368368
print!("\x1b]0;{}\x07", title);
369369
}

0 commit comments

Comments
 (0)