@@ -25,14 +25,14 @@ use crate::utils::tty::{stderr_isatty, stdout_isatty};
2525/// Allows concrete types for the currentprocess abstraction.
2626#[ derive( Clone , Debug ) ]
2727pub enum Process {
28- OSProcess ( OSProcess ) ,
28+ Os ( OSProcess ) ,
2929 #[ cfg( feature = "test" ) ]
30- TestProcess ( TestProcess ) ,
30+ Test ( TestProcess ) ,
3131}
3232
3333impl Process {
3434 pub fn os ( ) -> Self {
35- Self :: OSProcess ( OSProcess :: new ( ) )
35+ Self :: Os ( OSProcess :: new ( ) )
3636 }
3737
3838 pub fn name ( & self ) -> Option < String > {
@@ -50,9 +50,9 @@ impl Process {
5050
5151 pub fn var ( & self , key : & str ) -> Result < String , env:: VarError > {
5252 match self {
53- Process :: OSProcess ( _) => env:: var ( key) ,
53+ Process :: Os ( _) => env:: var ( key) ,
5454 #[ cfg( feature = "test" ) ]
55- Process :: TestProcess ( p) => match p. vars . get ( key) {
55+ Process :: Test ( p) => match p. vars . get ( key) {
5656 Some ( val) => Ok ( val. to_owned ( ) ) ,
5757 None => Err ( env:: VarError :: NotPresent ) ,
5858 } ,
@@ -61,100 +61,100 @@ impl Process {
6161
6262 pub ( crate ) fn var_os ( & self , key : & str ) -> Option < OsString > {
6363 match self {
64- Process :: OSProcess ( _) => env:: var_os ( key) ,
64+ Process :: Os ( _) => env:: var_os ( key) ,
6565 #[ cfg( feature = "test" ) ]
66- Process :: TestProcess ( p) => p. vars . get ( key) . map ( OsString :: from) ,
66+ Process :: Test ( p) => p. vars . get ( key) . map ( OsString :: from) ,
6767 }
6868 }
6969
7070 pub ( crate ) fn args ( & self ) -> Box < dyn Iterator < Item = String > + ' _ > {
7171 match self {
72- Process :: OSProcess ( _) => Box :: new ( env:: args ( ) ) ,
72+ Process :: Os ( _) => Box :: new ( env:: args ( ) ) ,
7373 #[ cfg( feature = "test" ) ]
74- Process :: TestProcess ( p) => Box :: new ( p. args . iter ( ) . cloned ( ) ) ,
74+ Process :: Test ( p) => Box :: new ( p. args . iter ( ) . cloned ( ) ) ,
7575 }
7676 }
7777
7878 pub ( crate ) fn args_os ( & self ) -> Box < dyn Iterator < Item = OsString > + ' _ > {
7979 match self {
80- Process :: OSProcess ( _) => Box :: new ( env:: args_os ( ) ) ,
80+ Process :: Os ( _) => Box :: new ( env:: args_os ( ) ) ,
8181 #[ cfg( feature = "test" ) ]
82- Process :: TestProcess ( p) => Box :: new ( p. args . iter ( ) . map ( OsString :: from) ) ,
82+ Process :: Test ( p) => Box :: new ( p. args . iter ( ) . map ( OsString :: from) ) ,
8383 }
8484 }
8585
8686 pub ( crate ) fn stdin ( & self ) -> Box < dyn filesource:: Stdin > {
8787 match self {
88- Process :: OSProcess ( _) => Box :: new ( io:: stdin ( ) ) ,
88+ Process :: Os ( _) => Box :: new ( io:: stdin ( ) ) ,
8989 #[ cfg( feature = "test" ) ]
90- Process :: TestProcess ( p) => Box :: new ( filesource:: TestStdin ( p. stdin . clone ( ) ) ) ,
90+ Process :: Test ( p) => Box :: new ( filesource:: TestStdin ( p. stdin . clone ( ) ) ) ,
9191 }
9292 }
9393
9494 pub ( crate ) fn stdout ( & self ) -> Box < dyn filesource:: Writer > {
9595 match self {
96- Process :: OSProcess ( _) => Box :: new ( io:: stdout ( ) ) ,
96+ Process :: Os ( _) => Box :: new ( io:: stdout ( ) ) ,
9797 #[ cfg( feature = "test" ) ]
98- Process :: TestProcess ( p) => Box :: new ( filesource:: TestWriter ( p. stdout . clone ( ) ) ) ,
98+ Process :: Test ( p) => Box :: new ( filesource:: TestWriter ( p. stdout . clone ( ) ) ) ,
9999 }
100100 }
101101
102102 pub ( crate ) fn stderr ( & self ) -> Box < dyn filesource:: Writer > {
103103 match self {
104- Process :: OSProcess ( _) => Box :: new ( io:: stderr ( ) ) ,
104+ Process :: Os ( _) => Box :: new ( io:: stderr ( ) ) ,
105105 #[ cfg( feature = "test" ) ]
106- Process :: TestProcess ( p) => Box :: new ( filesource:: TestWriter ( p. stderr . clone ( ) ) ) ,
106+ Process :: Test ( p) => Box :: new ( filesource:: TestWriter ( p. stderr . clone ( ) ) ) ,
107107 }
108108 }
109109
110110 pub ( crate ) fn current_dir ( & self ) -> io:: Result < PathBuf > {
111111 match self {
112- Process :: OSProcess ( _) => env:: current_dir ( ) ,
112+ Process :: Os ( _) => env:: current_dir ( ) ,
113113 #[ cfg( feature = "test" ) ]
114- Process :: TestProcess ( p) => Ok ( p. cwd . clone ( ) ) ,
114+ Process :: Test ( p) => Ok ( p. cwd . clone ( ) ) ,
115115 }
116116 }
117117
118118 #[ cfg( test) ]
119119 fn id ( & self ) -> u64 {
120120 match self {
121- Process :: OSProcess ( _) => std:: process:: id ( ) as u64 ,
121+ Process :: Os ( _) => std:: process:: id ( ) as u64 ,
122122 #[ cfg( feature = "test" ) ]
123- Process :: TestProcess ( p) => p. id ,
123+ Process :: Test ( p) => p. id ,
124124 }
125125 }
126126}
127127
128128impl home:: env:: Env for Process {
129129 fn home_dir ( & self ) -> Option < PathBuf > {
130130 match self {
131- Process :: OSProcess ( _) => self . var ( "HOME" ) . ok ( ) . map ( |v| v. into ( ) ) ,
131+ Process :: Os ( _) => self . var ( "HOME" ) . ok ( ) . map ( |v| v. into ( ) ) ,
132132 #[ cfg( feature = "test" ) ]
133- Process :: TestProcess ( _) => home:: env:: OS_ENV . home_dir ( ) ,
133+ Process :: Test ( _) => home:: env:: OS_ENV . home_dir ( ) ,
134134 }
135135 }
136136
137137 fn current_dir ( & self ) -> Result < PathBuf , io:: Error > {
138138 match self {
139- Process :: OSProcess ( _) => self . current_dir ( ) ,
139+ Process :: Os ( _) => self . current_dir ( ) ,
140140 #[ cfg( feature = "test" ) ]
141- Process :: TestProcess ( _) => home:: env:: OS_ENV . current_dir ( ) ,
141+ Process :: Test ( _) => home:: env:: OS_ENV . current_dir ( ) ,
142142 }
143143 }
144144
145145 fn var_os ( & self , key : & str ) -> Option < OsString > {
146146 match self {
147- Process :: OSProcess ( _) => self . var_os ( key) ,
147+ Process :: Os ( _) => self . var_os ( key) ,
148148 #[ cfg( feature = "test" ) ]
149- Process :: TestProcess ( _) => self . var_os ( key) ,
149+ Process :: Test ( _) => self . var_os ( key) ,
150150 }
151151 }
152152}
153153
154154#[ cfg( feature = "test" ) ]
155155impl From < TestProcess > for Process {
156156 fn from ( p : TestProcess ) -> Self {
157- Self :: TestProcess ( p)
157+ Self :: Test ( p)
158158 }
159159}
160160
0 commit comments