Struct zenv::Lines[][src]

pub struct Lines { /* 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

impl Lines[src]

pub fn to_hash_map(&self) -> HashMap<String, String>[src]

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());

pub fn expand(&self) -> HashMap<String, String>[src]

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

impl Debug for Lines[src]

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

Formats the value using the given formatter. Read more

impl From<&'_ str> for Lines[src]

fn from(lines: &str) -> Self[src]

Performs the conversion.

Auto Trait Implementations

impl RefUnwindSafe for Lines

impl Send for Lines

impl Sync for Lines

impl Unpin for Lines

impl UnwindSafe for Lines

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.