We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8ed74c4 commit 3a44b12Copy full SHA for 3a44b12
src/lib.rs
@@ -685,14 +685,15 @@ impl Shell {
685
/// If this is not desired, consider using
686
/// [`Shell::vars_os`](Self::vars_os).
687
pub fn vars(&self) -> Vec<(String, String)> {
688
- let mut vars = Vec::from_iter(
689
- self.env
690
- .borrow()
691
- .iter()
692
- .map(|(k, v)| (k.to_str().unwrap().to_string(), v.to_str().unwrap().to_string())),
693
- );
694
- vars.sort_unstable_by(|(a, _), (b, _)| a.cmp(b));
695
- vars
+ #[inline]
+ fn os_str_to_string(os_str: OsString) -> String {
+ os_str.to_str().unwrap().to_string()
+ }
+ // re-use functionality from `Self::vars_os` to reduce code repetition
+ self.vars_os()
+ .into_iter()
+ .map(|(k, v)| (os_str_to_string(k), os_str_to_string(v)))
696
+ .collect()
697
}
698
699
0 commit comments