diff --git a/src/command/mod.rs b/src/command/mod.rs index 1f28de0..3a955a6 100644 --- a/src/command/mod.rs +++ b/src/command/mod.rs @@ -9,9 +9,6 @@ use crate::variables::Variables; type BuiltinFunction = fn(&Vec, &mut Variables, &mut ExitCode); -#[derive(Debug)] -pub struct NoSuchBuiltinError; - pub trait Command { fn spawn(&mut self, variables: &mut Variables, exit_code: &mut ExitCode); } @@ -22,7 +19,7 @@ pub struct Builtin { } impl Builtin { - pub fn new(argv: &Vec) -> Result { + pub fn new(argv: &Vec) -> Result { let mut args = argv.clone(); let program = args.remove(0); @@ -35,13 +32,9 @@ impl Builtin { _ => None, }; - if function.is_some() { - Ok(Self { - function: function.unwrap(), - args, - }) - } else { - Err(NoSuchBuiltinError) + match function { + Some(function) => Ok(Self { function, args }), + None => Err(()), } } }