pub fn subst_envar(s: &str) -> Result<String> {
	let mut res = String::new();
	for token in SubstIterator::new(s) {
		match token {
			Token::Str(chunk) => {
				res += chunk;
			}
			Token::Var(name) => {
				let val = env::var(name).map_err(|e| Error::UnknownVar(name.to_owned(), e))?;
				res += &val;
			}
			Token::BraceError => return Err(Error::RightBrace),
		}
	}
	Ok(res)
}
/// return expr with expression ${VAR} subsitued by variable content
/// TODO: use a COW
return expr with expression ${VAR} subsitued by variable content
TODO: use a COW
return expr with expression $ { VAR } subsitued by variable content TODO : use a COW
pub fn subst_envar(s: &str) -> Result<String> {
	let mut res = String::new();
	for token in SubstIterator::new(s) {
		match token {
			Token::Str(chunk) => {
				res += chunk;
			}
			Token::Var(name) => {
				let val = env::var(name).map_err(|e| Error::UnknownVar(name.to_owned(), e))?;
				res += &val;
			}
			Token::BraceError => return Err(Error::RightBrace),
		}
	}
	Ok(res)
}
pub fn subst_envar ( s : & str ) -> Result < String > { let mut res = String :: new ( ) ; for token in SubstIterator :: new ( s ) { match token { Token :: Str ( chunk ) => { res += chunk ; } Token :: Var ( name ) => { let val = env :: var ( name ) . map_err ( | e | Error :: UnknownVar ( name . to_owned ( ) , e ) ) ? ; res += & val ; } Token :: BraceError => return Err ( Error :: RightBrace ) , } } Ok ( res ) }
return expr with expression ${VAR} subsitued by variable content
TODO: use a COW
return expr with expression $ { VAR } subsitued by variable content TODO : use a COW
s
&str
s
&str