diff options
author | Canop <cano.petrole@gmail.com> | 2020-09-29 16:56:46 +0200 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2020-09-29 16:56:46 +0200 |
commit | c0b0b283dc2b24c3469339ebf61c28fda1e0efbb (patch) | |
tree | ca0dd838237e7a46e660d94f3f918fac4417ace5 /src/verb/verb_store.rs | |
parent | 46316405917f92e622cdb6e0b29dd769afb65206 (diff) |
refactor verb initialization from conf
removing the useless step of VerbConf and VerbConfExecutionType
Diffstat (limited to 'src/verb/verb_store.rs')
-rw-r--r-- | src/verb/verb_store.rs | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/src/verb/verb_store.rs b/src/verb/verb_store.rs index 73e86c1..e0c291a 100644 --- a/src/verb/verb_store.rs +++ b/src/verb/verb_store.rs @@ -1,7 +1,7 @@ use { super::{ builtin::builtin_verbs, - internal::Internal, + Internal, Verb, }, crate::{ @@ -10,7 +10,6 @@ use { keys, }, crossterm::event::KeyEvent, - std::convert::TryFrom, }; /// Provide access to the verbs: @@ -33,20 +32,11 @@ pub enum PrefixSearchResult<'v, T> { } impl VerbStore { - pub fn init(&mut self, conf: &Conf) { - // we first add the verbs coming from configuration, as - // we'll search in order. This way, a user can overload a - // standard verb. - for verb_conf in &conf.verbs { - match Verb::try_from(verb_conf) { - Ok(v) => { - self.verbs.push(v); - } - Err(e) => { - eprintln!("Verb error: {:?}", e); - } - } - } + pub fn init(&mut self, conf: &mut Conf) { + // We first add the verbs coming from configuration, as we'll search in order. + // This way, a user can overload a standard verb. + // Note that we remove the verbs from conf, assuming they won't be needed anymore. + self.verbs.extend(conf.verbs.drain(..)); self.verbs.extend(builtin_verbs()); } |