pub struct VarEnv { /* private fields */ }Expand description
Environment map used by expand.
Keys are stored case-sensitively in inner so iter-style consumers
(and debug output) see the original casing pack authors wrote. Lookup
via VarEnv::get is platform-aware:
- Unix/macOS — direct case-sensitive lookup.
- Windows — case-insensitive: a secondary
lookup_indexmaps the ASCII-lowercased key to the original-cased key ininner. This mirrors OS behaviour where%Path%and%PATH%name the same var.
The double-map costs ~1 pointer per entry on Windows only. No new deps
(UniCase et al. considered and rejected).
Implementations§
Source§impl VarEnv
impl VarEnv
Sourcepub fn from_os() -> Self
pub fn from_os() -> Self
Construct an environment snapshot from the current process.
Uses std::env::vars. On Windows, after collecting the snapshot a
HOME → %USERPROFILE% fallback is materialised as a real entry when
HOME is absent and USERPROFILE is present, so pack authors can
write ${HOME} portably. The fallback is applied in from_os only
— never in VarEnv::new or VarEnv::insert — so tests that
build envs explicitly see only what they inserted.
Sourcepub fn from_map(map: HashMap<String, String>) -> Self
pub fn from_map(map: HashMap<String, String>) -> Self
Build a VarEnv from an explicit map, applying the same Windows
HOME→USERPROFILE fallback as VarEnv::from_os.
Exposed primarily for tests and advanced callers that construct a
synthetic environment. On non-Windows targets this is a thin
wrapper around the map; on Windows it populates lookup_index and
the HOME fallback.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for VarEnv
impl RefUnwindSafe for VarEnv
impl Send for VarEnv
impl Sync for VarEnv
impl Unpin for VarEnv
impl UnsafeUnpin for VarEnv
impl UnwindSafe for VarEnv
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more