diff options
| author | Tamir Duberstein <tamird@gmail.com> | 2023-07-27 10:59:11 -0400 |
|---|---|---|
| committer | Tamir Duberstein <tamird@gmail.com> | 2023-08-07 12:18:27 -0400 |
| commit | 35c0c03a3c3713a0ff68f826c478abcea7135cbb (patch) | |
| tree | a619decde0f40c5d4c4c889094a35c329bf2ad64 /library/std/src/sys/solid/os.rs | |
| parent | fbc11e96901a1f1a0cc865867f38684af250249f (diff) | |
| download | rust-35c0c03a3c3713a0ff68f826c478abcea7135cbb.tar.gz rust-35c0c03a3c3713a0ff68f826c478abcea7135cbb.zip | |
Better Debug for Vars and VarsOs
Display actual vars instead of two dots. The same was done for Args and ArgsOs in 275f9a04af6191e3aee3852a5a1713.
Diffstat (limited to 'library/std/src/sys/solid/os.rs')
| -rw-r--r-- | library/std/src/sys/solid/os.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/library/std/src/sys/solid/os.rs b/library/std/src/sys/solid/os.rs index 6135921f0b5..717c08434a8 100644 --- a/library/std/src/sys/solid/os.rs +++ b/library/std/src/sys/solid/os.rs @@ -85,6 +85,34 @@ pub struct Env { iter: vec::IntoIter<(OsString, OsString)>, } +// FIXME(https://github.com/rust-lang/rust/issues/114583): Remove this when <OsStr as Debug>::fmt matches <str as Debug>::fmt. +pub struct EnvStrDebug<'a> { + slice: &'a [(OsString, OsString)], +} + +impl fmt::Debug for EnvStrDebug<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let Self { slice } = self; + f.debug_list() + .entries(slice.iter().map(|(a, b)| (a.to_str().unwrap(), b.to_str().unwrap()))) + .finish() + } +} + +impl Env { + pub fn str_debug(&self) -> impl fmt::Debug + '_ { + let Self { iter } = self; + EnvStrDebug { slice: iter.as_slice() } + } +} + +impl fmt::Debug for Env { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let Self { iter } = self; + f.debug_list().entries(iter.as_slice()).finish() + } +} + impl !Send for Env {} impl !Sync for Env {} |
