Struct zenv::Lines[][src]

pub struct Lines<'l> { /* fields omitted */ }
Expand description

Lines is used to parse the sequence of lines

Zenv is built on top it. And if you want you can directly use this but don’t :)

Implementations

Create Lines from a vec of Line. Can be useful if you manually parsing individual lines

Example

use zenv::{Lines, Line};

let lines = vec![
    Line::from("BASIC=basic"),
    Line::Empty,
    Line::from("QUOTED='quoted'")
];

let parsed = Lines::new(lines).to_hash_map();

assert_eq!(parsed.get("BASIC").unwrap(), &"basic".to_string());
assert_eq!(parsed.get("QUOTED").unwrap(), &"quoted".to_string());

Parses the lines and converts into a hashmap

Example

use zenv::Lines;

const LINES: &str = r#"
BASIC=basic
QUOTED='quoted'
"#;

let parsed = Lines::from(LINES).to_hash_map();

assert_eq!(parsed.get("BASIC").unwrap(), &"basic".to_string());
assert_eq!(parsed.get("QUOTED").unwrap(), &"quoted".to_string());

Parses the lines and does variable substitution then converts into a hashmap

Example

use zenv::Lines;

const LINES: &str = r#"
BASIC=basic
EXPANDED="${BASIC}_is_expanded"
"#;

let parsed = Lines::from(LINES).expand();

assert_eq!(parsed.get("BASIC").unwrap(), &"basic".to_string());
assert_eq!(parsed.get("EXPANDED").unwrap(), &"basic_is_expanded".to_string());

Trait Implementations

Formats the value using the given formatter. Read more

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.