Skip to content

Commit ef95185

Browse files
committed
Rename Process variants to avoid stuttering
1 parent ad83f8c commit ef95185

File tree

3 files changed

+36
-36
lines changed

3 files changed

+36
-36
lines changed

src/currentprocess/filesource.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ impl WriterLock for io::StdoutLock<'_> {}
9393
impl Writer for io::Stdout {
9494
fn is_a_tty(&self) -> bool {
9595
match process() {
96-
crate::currentprocess::Process::OSProcess(p) => p.stdout_is_a_tty,
96+
crate::currentprocess::Process::Os(p) => p.stdout_is_a_tty,
9797
#[cfg(feature = "test")]
98-
crate::currentprocess::Process::TestProcess(_) => unreachable!(),
98+
crate::currentprocess::Process::Test(_) => unreachable!(),
9999
}
100100
}
101101

@@ -113,9 +113,9 @@ impl WriterLock for io::StderrLock<'_> {}
113113
impl Writer for io::Stderr {
114114
fn is_a_tty(&self) -> bool {
115115
match process() {
116-
crate::currentprocess::Process::OSProcess(p) => p.stderr_is_a_tty,
116+
crate::currentprocess::Process::Os(p) => p.stderr_is_a_tty,
117117
#[cfg(feature = "test")]
118-
crate::currentprocess::Process::TestProcess(_) => unreachable!(),
118+
crate::currentprocess::Process::Test(_) => unreachable!(),
119119
}
120120
}
121121

src/currentprocess/mod.rs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ pub mod terminalsource;
2323
/// Allows concrete types for the currentprocess abstraction.
2424
#[derive(Clone, Debug)]
2525
pub enum Process {
26-
OSProcess(OSProcess),
26+
Os(OSProcess),
2727
#[cfg(feature = "test")]
28-
TestProcess(TestProcess),
28+
Test(TestProcess),
2929
}
3030

3131
impl Process {
3232
pub fn os() -> Self {
33-
Self::OSProcess(OSProcess::new())
33+
Self::Os(OSProcess::new())
3434
}
3535

3636
pub fn name(&self) -> Option<String> {
@@ -48,9 +48,9 @@ impl Process {
4848

4949
pub fn var(&self, key: &str) -> Result<String, env::VarError> {
5050
match self {
51-
Process::OSProcess(_) => env::var(key),
51+
Process::Os(_) => env::var(key),
5252
#[cfg(feature = "test")]
53-
Process::TestProcess(p) => match p.vars.get(key) {
53+
Process::Test(p) => match p.vars.get(key) {
5454
Some(val) => Ok(val.to_owned()),
5555
None => Err(env::VarError::NotPresent),
5656
},
@@ -59,100 +59,100 @@ impl Process {
5959

6060
pub(crate) fn var_os(&self, key: &str) -> Option<OsString> {
6161
match self {
62-
Process::OSProcess(_) => env::var_os(key),
62+
Process::Os(_) => env::var_os(key),
6363
#[cfg(feature = "test")]
64-
Process::TestProcess(p) => p.vars.get(key).map(OsString::from),
64+
Process::Test(p) => p.vars.get(key).map(OsString::from),
6565
}
6666
}
6767

6868
pub(crate) fn args(&self) -> Box<dyn Iterator<Item = String> + '_> {
6969
match self {
70-
Process::OSProcess(_) => Box::new(env::args()),
70+
Process::Os(_) => Box::new(env::args()),
7171
#[cfg(feature = "test")]
72-
Process::TestProcess(p) => Box::new(p.args.iter().cloned()),
72+
Process::Test(p) => Box::new(p.args.iter().cloned()),
7373
}
7474
}
7575

7676
pub(crate) fn args_os(&self) -> Box<dyn Iterator<Item = OsString> + '_> {
7777
match self {
78-
Process::OSProcess(_) => Box::new(env::args_os()),
78+
Process::Os(_) => Box::new(env::args_os()),
7979
#[cfg(feature = "test")]
80-
Process::TestProcess(p) => Box::new(p.args.iter().map(OsString::from)),
80+
Process::Test(p) => Box::new(p.args.iter().map(OsString::from)),
8181
}
8282
}
8383

8484
pub(crate) fn stdin(&self) -> Box<dyn filesource::Stdin> {
8585
match self {
86-
Process::OSProcess(_) => Box::new(io::stdin()),
86+
Process::Os(_) => Box::new(io::stdin()),
8787
#[cfg(feature = "test")]
88-
Process::TestProcess(p) => Box::new(filesource::TestStdin(p.stdin.clone())),
88+
Process::Test(p) => Box::new(filesource::TestStdin(p.stdin.clone())),
8989
}
9090
}
9191

9292
pub(crate) fn stdout(&self) -> Box<dyn filesource::Writer> {
9393
match self {
94-
Process::OSProcess(_) => Box::new(io::stdout()),
94+
Process::Os(_) => Box::new(io::stdout()),
9595
#[cfg(feature = "test")]
96-
Process::TestProcess(p) => Box::new(filesource::TestWriter(p.stdout.clone())),
96+
Process::Test(p) => Box::new(filesource::TestWriter(p.stdout.clone())),
9797
}
9898
}
9999

100100
pub(crate) fn stderr(&self) -> Box<dyn filesource::Writer> {
101101
match self {
102-
Process::OSProcess(_) => Box::new(io::stderr()),
102+
Process::Os(_) => Box::new(io::stderr()),
103103
#[cfg(feature = "test")]
104-
Process::TestProcess(p) => Box::new(filesource::TestWriter(p.stderr.clone())),
104+
Process::Test(p) => Box::new(filesource::TestWriter(p.stderr.clone())),
105105
}
106106
}
107107

108108
pub(crate) fn current_dir(&self) -> io::Result<PathBuf> {
109109
match self {
110-
Process::OSProcess(_) => env::current_dir(),
110+
Process::Os(_) => env::current_dir(),
111111
#[cfg(feature = "test")]
112-
Process::TestProcess(p) => Ok(p.cwd.clone()),
112+
Process::Test(p) => Ok(p.cwd.clone()),
113113
}
114114
}
115115

116116
#[cfg(test)]
117117
fn id(&self) -> u64 {
118118
match self {
119-
Process::OSProcess(_) => std::process::id() as u64,
119+
Process::Os(_) => std::process::id() as u64,
120120
#[cfg(feature = "test")]
121-
Process::TestProcess(p) => p.id,
121+
Process::Test(p) => p.id,
122122
}
123123
}
124124
}
125125

126126
impl home::env::Env for Process {
127127
fn home_dir(&self) -> Option<PathBuf> {
128128
match self {
129-
Process::OSProcess(_) => self.var("HOME").ok().map(|v| v.into()),
129+
Process::Os(_) => self.var("HOME").ok().map(|v| v.into()),
130130
#[cfg(feature = "test")]
131-
Process::TestProcess(_) => home::env::OS_ENV.home_dir(),
131+
Process::Test(_) => home::env::OS_ENV.home_dir(),
132132
}
133133
}
134134

135135
fn current_dir(&self) -> Result<PathBuf, io::Error> {
136136
match self {
137-
Process::OSProcess(_) => self.current_dir(),
137+
Process::Os(_) => self.current_dir(),
138138
#[cfg(feature = "test")]
139-
Process::TestProcess(_) => home::env::OS_ENV.current_dir(),
139+
Process::Test(_) => home::env::OS_ENV.current_dir(),
140140
}
141141
}
142142

143143
fn var_os(&self, key: &str) -> Option<OsString> {
144144
match self {
145-
Process::OSProcess(_) => self.var_os(key),
145+
Process::Os(_) => self.var_os(key),
146146
#[cfg(feature = "test")]
147-
Process::TestProcess(_) => self.var_os(key),
147+
Process::Test(_) => self.var_os(key),
148148
}
149149
}
150150
}
151151

152152
#[cfg(feature = "test")]
153153
impl From<TestProcess> for Process {
154154
fn from(p: TestProcess) -> Self {
155-
Self::TestProcess(p)
155+
Self::Test(p)
156156
}
157157
}
158158

src/currentprocess/terminalsource.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ impl StreamSelector {
2727
fn is_a_tty(&self) -> bool {
2828
match self {
2929
StreamSelector::Stdout => match process() {
30-
super::Process::OSProcess(p) => p.stdout_is_a_tty,
30+
super::Process::Os(p) => p.stdout_is_a_tty,
3131
#[cfg(feature = "test")]
32-
super::Process::TestProcess(_) => unreachable!(),
32+
super::Process::Test(_) => unreachable!(),
3333
},
3434
StreamSelector::Stderr => match process() {
35-
super::Process::OSProcess(p) => p.stderr_is_a_tty,
35+
super::Process::Os(p) => p.stderr_is_a_tty,
3636
#[cfg(feature = "test")]
37-
super::Process::TestProcess(_) => unreachable!(),
37+
super::Process::Test(_) => unreachable!(),
3838
},
3939
#[cfg(feature = "test")]
4040
StreamSelector::TestWriter(_) => false,

0 commit comments

Comments
 (0)