File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -220,14 +220,13 @@ impl fmt::Debug for VarsOs {
220220/// ```
221221#[ stable( feature = "env" , since = "1.0.0" ) ]
222222pub fn var < K : AsRef < OsStr > > ( key : K ) -> Result < String , VarError > {
223- _var ( key. as_ref ( ) )
224- }
225-
226- fn _var ( key : & OsStr ) -> Result < String , VarError > {
227- match var_os ( key) {
228- Some ( s) => s. into_string ( ) . map_err ( VarError :: NotUnicode ) ,
229- None => Err ( VarError :: NotPresent ) ,
223+ fn inner ( key : & OsStr ) -> Result < String , VarError > {
224+ env_imp:: getenv ( key)
225+ . ok_or ( VarError :: NotPresent ) ?
226+ . into_string ( )
227+ . map_err ( VarError :: NotUnicode )
230228 }
229+ inner ( key. as_ref ( ) )
231230}
232231
233232/// Fetches the environment variable `key` from the current process, returning
@@ -257,11 +256,7 @@ fn _var(key: &OsStr) -> Result<String, VarError> {
257256#[ must_use]
258257#[ stable( feature = "env" , since = "1.0.0" ) ]
259258pub fn var_os < K : AsRef < OsStr > > ( key : K ) -> Option < OsString > {
260- _var_os ( key. as_ref ( ) )
261- }
262-
263- fn _var_os ( key : & OsStr ) -> Option < OsString > {
264- env_imp:: getenv ( key)
259+ env_imp:: getenv ( key. as_ref ( ) )
265260}
266261
267262/// The error type for operations interacting with environment variables.
You can’t perform that action at this time.
0 commit comments