Skip to content

Commit 8e632bb

Browse files
authored
Merge pull request #2745 from hi-rustin/rustin-patch-cleanup-currentprocess
Make some pub structs/functions crate-public
2 parents 44be718 + 1d03dbc commit 8e632bb

File tree

5 files changed

+27
-22
lines changed

5 files changed

+27
-22
lines changed

src/cli/term2.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ mod termhack {
103103
// - Disable all terminal controls on non-tty's
104104
// - Swallow errors when we try to use features a terminal doesn't have
105105
// such as setting colours when no TermInfo DB is present
106-
pub struct AutomationFriendlyTerminal<T>(Box<dyn term::Terminal<Output = T> + Send>)
106+
pub(crate) struct AutomationFriendlyTerminal<T>(Box<dyn term::Terminal<Output = T> + Send>)
107107
where
108108
T: Isatty + io::Write;
109-
pub type StdoutTerminal = AutomationFriendlyTerminal<Box<dyn Writer>>;
110-
pub type StderrTerminal = AutomationFriendlyTerminal<Box<dyn Writer>>;
109+
pub(crate) type StdoutTerminal = AutomationFriendlyTerminal<Box<dyn Writer>>;
110+
pub(crate) type StderrTerminal = AutomationFriendlyTerminal<Box<dyn Writer>>;
111111

112112
macro_rules! swallow_unsupported {
113113
( $call:expr ) => {{
@@ -225,14 +225,14 @@ lazy_static! {
225225
Mutex::new(term::terminfo::TermInfo::from_env().ok());
226226
}
227227

228-
pub fn stdout() -> StdoutTerminal {
228+
pub(crate) fn stdout() -> StdoutTerminal {
229229
let info_result = TERMINFO.lock().unwrap().clone();
230230
AutomationFriendlyTerminal(termhack::make_terminal_with_fallback(info_result, || {
231231
process().stdout()
232232
}))
233233
}
234234

235-
pub fn stderr() -> StderrTerminal {
235+
pub(crate) fn stderr() -> StderrTerminal {
236236
let info_result = TERMINFO.lock().unwrap().clone();
237237
AutomationFriendlyTerminal(termhack::make_terminal_with_fallback(info_result, || {
238238
process().stderr()

src/currentprocess.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ use std::sync::{Arc, Mutex};
1111

1212
use rand::{thread_rng, Rng};
1313

14-
pub mod argsource;
15-
pub mod cwdsource;
16-
pub mod filesource;
14+
pub(crate) mod argsource;
15+
pub(crate) mod cwdsource;
16+
pub(crate) mod filesource;
1717
mod homethunk;
18-
pub mod varsource;
18+
pub(crate) mod varsource;
1919

2020
use argsource::*;
2121
use cwdsource::*;
@@ -121,7 +121,7 @@ pub fn process() -> Box<dyn CurrentProcess> {
121121
}
122122

123123
/// Obtain the current instance of HomeProcess
124-
pub fn home_process() -> Box<dyn HomeProcess> {
124+
pub(crate) fn home_process() -> Box<dyn HomeProcess> {
125125
match PROCESS.with(|p| p.borrow().clone()) {
126126
None => panic!("No process instance"),
127127
Some(p) => p,
@@ -163,7 +163,7 @@ fn clear_process() {
163163
}
164164

165165
thread_local! {
166-
pub static PROCESS:RefCell<Option<Box<dyn HomeProcess>>> = RefCell::new(None);
166+
pub(crate) static PROCESS:RefCell<Option<Box<dyn HomeProcess>>> = RefCell::new(None);
167167
}
168168

169169
// PID related things
@@ -191,13 +191,13 @@ impl ProcessSource for OSProcess {
191191

192192
#[derive(Clone, Debug, Default)]
193193
pub struct TestProcess {
194-
pub cwd: PathBuf,
195-
pub args: Vec<String>,
196-
pub vars: HashMap<String, String>,
197-
pub id: u64,
198-
pub stdin: TestStdinInner,
199-
pub stdout: TestWriterInner,
200-
pub stderr: TestWriterInner,
194+
pub(crate) cwd: PathBuf,
195+
pub(crate) args: Vec<String>,
196+
pub(crate) vars: HashMap<String, String>,
197+
pub(crate) id: u64,
198+
pub(crate) stdin: TestStdinInner,
199+
pub(crate) stdout: TestWriterInner,
200+
pub(crate) stderr: TestWriterInner,
201201
}
202202

203203
impl TestProcess {

src/currentprocess/argsource.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl ArgSource for super::OSProcess {
2020
}
2121

2222
/// Helper for ArgSource over `Vec<String>`
23-
pub struct VecArgs<T> {
23+
pub(crate) struct VecArgs<T> {
2424
v: Vec<String>,
2525
i: usize,
2626
_marker: PhantomData<T>,

src/currentprocess/filesource.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl BufRead for TestStdinLock<'_> {
5858
}
5959
}
6060

61-
pub type TestStdinInner = Arc<Mutex<Cursor<String>>>;
61+
pub(crate) type TestStdinInner = Arc<Mutex<Cursor<String>>>;
6262

6363
struct TestStdin(TestStdinInner);
6464

@@ -165,7 +165,7 @@ impl Write for TestWriterLock<'_> {
165165
}
166166
}
167167

168-
pub type TestWriterInner = Arc<Mutex<Vec<u8>>>;
168+
pub(crate) type TestWriterInner = Arc<Mutex<Vec<u8>>>;
169169

170170
struct TestWriter(TestWriterInner);
171171

tests/mock/clitools.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,12 @@ where
600600
output
601601
}
602602

603-
pub fn run_inprocess<I, A>(config: &Config, name: &str, args: I, env: &[(&str, &str)]) -> Output
603+
pub(crate) fn run_inprocess<I, A>(
604+
config: &Config,
605+
name: &str,
606+
args: I,
607+
env: &[(&str, &str)],
608+
) -> Output
604609
where
605610
I: IntoIterator<Item = A>,
606611
A: AsRef<OsStr>,

0 commit comments

Comments
 (0)