Skip to main content

Env

Struct Env 

Source
pub struct Env { /* private fields */ }
Expand description

Environment variables, looked up by name.

Implementations§

Source§

impl Env

Source

pub fn search_dirs(&self) -> Vec<PathBuf>

The directories on PATH a program is searched in, in order: only absolute ones. An empty or relative entry would be resolved against cuno’s working directory, often the project, which can hold a file named like the program (docs/en/specs/toolchain.md, “LLVM (clang / clang-cl / clang-format / clang-tidy)”).

Source

pub fn case(&self) -> NameCase

How this environment’s names are compared, which is how the system it came from compares file names too.

Source

pub fn from_process() -> Env

The environment of the running process. Only the binary calls this.

Source

pub fn from_pairs( pairs: impl IntoIterator<Item = (OsString, OsString)>, case: NameCase, ) -> Env

An environment holding exactly pairs, with names compared as case says; a later pair replaces an earlier one with the same name.

Source

pub fn get(&self, name: &str) -> Option<&OsStr>

The value of name, if it is set.

Source

pub fn set_value(&self, name: &str) -> Option<&OsStr>

The value of cuno’s own variable name (CUNO_HOME and the like), or None when it is unset or empty: an empty one counts as unset (docs/en/specs/manifest.md, “Two levels of settings”). Not for NO_COLOR, which is set even when empty.

Source

pub fn vars(&self) -> impl Iterator<Item = (&OsStr, &OsStr)>

Every variable, as (name as spelled, value), for giving a child process exactly this environment.

Source

pub fn with(&self, name: &str, value: OsString) -> Env

This environment with name set to value, replacing any variable that has the same name as this environment compares names.

Source

pub fn without(&self, names: &[&str]) -> Env

This environment without the variables named in names, compared as this environment compares names.

Trait Implementations§

Source§

impl Clone for Env

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Env

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Env

Source§

fn default() -> Env

An empty environment that compares names as this platform does.

Auto Trait Implementations§

§

impl Forget for Env

§

impl Freeze for Env
where *const LeafNode<OsString, (OsString, OsString)> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(OsString, (OsString, OsString))>>: Freeze,

§

impl Move for Env

§

impl RefUnwindSafe for Env

§

impl Send for Env
where NodeRef<Owned, OsString, (OsString, OsString), LeafOrInternal>: Send, BoxRaw<(OsString, (OsString, OsString))>: Send,

§

impl Sync for Env
where NodeRef<Owned, OsString, (OsString, OsString), LeafOrInternal>: Sync, BoxRaw<(OsString, (OsString, OsString))>: Sync,

§

impl Unpin for Env
where *const LeafNode<OsString, (OsString, OsString)> is !null: Unpin, Box<(OsString, (OsString, OsString))>: Unpin,

§

impl UnsafeUnpin for Env
where *const LeafNode<OsString, (OsString, OsString)> is !null: UnsafeUnpin, PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin, PhantomData<Box<(OsString, (OsString, OsString))>>: UnsafeUnpin,

§

impl UnwindSafe for Env

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.