a rust moment

master
Avril 4 years ago
parent f27dceed24
commit a0fc94d960
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -9,17 +9,18 @@ use sexp::{
Atom, Atom,
}; };
fn get_atom_string<'a, T>(maybe_atom: T) -> Result<&'a String, Error> fn get_atom_string<'a>(maybe_atom: &'a Sexp) -> Result<&'a String, Error>
where T: AsRef<Sexp> + 'a
{ {
match maybe_atom.as_ref() { match &maybe_atom {
Sexp::Atom(Atom::S(string)) => Ok(string), Sexp::Atom(Atom::S(string)) => Ok(string),
_ => Err(Error::InvalidSexp), _ => Err(Error::InvalidSexp),
} }
} }
fn new_job(to: &mut Config, cdr: &[Sexp]) -> Result<(), Error> { fn new_job(to: &mut Config, cdr: &[Sexp]) -> Result<(), Error> {
to.job_dirs.push(PathBuf::from(get_atom_string(&cdr[0])?)); let what = &cdr[0];
let what = get_atom_string(what)?;
to.job_dirs.push(PathBuf::from(what));
Ok(()) Ok(())
} }

Loading…
Cancel
Save