Enum bash_builtins::variables::Variable [−][src]
Expand description
Contains the value of a shell variable.
Use find or RawVariable::get to get this value.
Example
A function to print the value of var.
use bash_builtins::variables::Variable;
use std::io::{self, Write};
fn print<W>(mut output: W, name: &str, var: &Variable) -> io::Result<()>
where
W: Write,
{
match var {
Variable::Str(s) => {
writeln!(output, "{} = {:?}", name, s)?;
}
Variable::Array(a) => {
for (idx, elem) in a.iter().enumerate() {
writeln!(&mut output, "{}[{}] = {:?}", name, idx, elem)?;
}
}
Variable::Assoc(a) => {
for (key, value) in a.iter() {
writeln!(&mut output, "{}[{:?}] = {:?}", name, key, value)?;
}
}
}
Ok(())
}Variants
A single string.
Tuple Fields of Str
0: CStringAn indexed array.
An associative array.
These shell variables are initialized with declare -A.