pub struct Variable { /* private fields */ }Expand description
One environment variable of an external command
A variable carries a name and a value. The command reads the variable in its environment, next to the variables that it inherits from the process that runs it. Some programs take a decision from a variable and from no flag, such as a test runner that selects the format of its report with one.
A pair of a name and a value becomes a variable, so a caller that holds its variables as pairs gives them to an invocation as they are.
§Examples
use kawauso_process::invocation::Variable;
let variable = Variable::from(("RUSTUP_TOOLCHAIN", "stable"));
assert_eq!(variable.name().get(), "RUSTUP_TOOLCHAIN");Implementations§
Source§impl Variable
impl Variable
Sourcepub fn new(
name: impl Into<VariableName>,
value: impl Into<VariableValue>,
) -> Self
pub fn new( name: impl Into<VariableName>, value: impl Into<VariableValue>, ) -> Self
Creates a variable from a name and a value
§Examples
use kawauso_process::invocation::Variable;
let variable = Variable::new("CARGO_TERM_COLOR", "always");
assert_eq!(variable.value().get(), "always");Sourcepub fn name(&self) -> &VariableName
pub fn name(&self) -> &VariableName
Returns the name of the variable
Sourcepub fn value(&self) -> &VariableValue
pub fn value(&self) -> &VariableValue
Returns the value of the variable
Trait Implementations§
Source§impl Display for Variable
Shows the variable for a reader
impl Display for Variable
Shows the variable for a reader
The text is the name, an equals sign, and the value, which is the form in which a shell sets a variable. A value that holds a space shows without marks, because the caller that renders a whole command line adds the marks where the line needs them.
impl Eq for Variable
Source§impl<N: Into<VariableName>, V: Into<VariableValue>> From<(N, V)> for Variable
Creates a variable from a pair of a name and a value
impl<N: Into<VariableName>, V: Into<VariableValue>> From<(N, V)> for Variable
Creates a variable from a pair of a name and a value