pub fn replace_vars<S>(&self, data: &S) -> Value
    where
        S: ?Sized + Hash + Eq + ToString,
        Key: Borrow<S>,
    {
        let mut res = data.to_string();
        for (k, v) in &self.env {
            // Bracketed version always replaces.
            res = res.replace(&format!("${{{}}}", k), v);

            // Non-bracketed version can only replace when complete subset of string. For instance,
            // "$USER" must not replace in "$USERNAME" but "$USERNAME" can since it's the complete
            // string.
            let lookfor = format!("${}", k);
            res = ENV_VAR_REGEX
                .replace_all(&res, |caps: &Captures| {
                    let m = caps.get(0).unwrap().as_str();
                    if m == lookfor {
                        v.to_string()
                    } else {
                        m.to_string()
                    }
                })
                .into_owned();
        }
        res
    }
/// Replaces all environment variables in \p data and returns resulting string.
Replaces all environment variables in \p data and returns resulting string.
Replaces all environment variables in \ p data and returns resulting string .
pub fn replace_vars<S>(&self, data: &S) -> Value
    where
        S: ?Sized + Hash + Eq + ToString,
        Key: Borrow<S>,
    {
        let mut res = data.to_string();
        for (k, v) in &self.env {
            // Bracketed version always replaces.
            res = res.replace(&format!("${{{}}}", k), v);
            // Non-bracketed version can only replace when complete subset of string. For instance,
            // "$USER" must not replace in "$USERNAME" but "$USERNAME" can since it's the complete
            // string.
            let lookfor = format!("${}", k);
            res = ENV_VAR_REGEX
                .replace_all(&res, |caps: &Captures| {
                    let m = caps.get(0).unwrap().as_str();
                    if m == lookfor {
                        v.to_string()
                    } else {
                        m.to_string()
                    }
                })
                .into_owned();
        }
        res
    }
pub fn replace_vars < S > ( & self , data : & S ) -> Value where S : ? Sized + Hash + Eq + ToString , Key : Borrow < S > , { let mut res = data . to_string ( ) ; for ( k , v ) in & self . env { // Bracketed version always replaces. res = res . replace ( & format ! ( " " k ) , v ) ; // Non-bracketed version can only replace when complete subset of string. For instance, // "$USER" must not replace in "$USERNAME" but "$USERNAME" can since it's the complete // string. let lookfor = format ! ( " " k ) ; res = ENV_VAR_REGEX . replace_all ( & res , | caps : & Captures | { let m = caps . get ( 0 ) . unwrap ( ) . as_str ( ) ; if m == lookfor { v . to_string ( ) } else { m . to_string ( ) } } ) . into_owned ( ) ; } res }
Replaces all environment variables in \p data and returns resulting string.
Replaces all environment variables in \ p data and returns resulting string .
&self
data
&S