We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f9d1c3e commit aa68cbbCopy full SHA for aa68cbb
src/lib.rs
@@ -685,14 +685,12 @@ 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))).collect()
696
}
697
698
0 commit comments