summaryrefslogtreecommitdiffstats
path: root/src/command
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2020-12-11 13:12:05 +0100
committerCanop <cano.petrole@gmail.com>2020-12-11 13:12:05 +0100
commitaab4f13284e2b61e485aeb898b84e2332c968227 (patch)
treeec5b936355017bf05f70ce9cf6fe75f5e2e239e6 /src/command
parentf6efb7456752ac0fcd603d5c2afbb9a0118f630c (diff)
use serde's derive to deserialize conf
Diffstat (limited to 'src/command')
-rw-r--r--src/command/completion.rs4
-rw-r--r--src/command/sequence.rs6
2 files changed, 5 insertions, 5 deletions
diff --git a/src/command/completion.rs b/src/command/completion.rs
index bf647a2..1b479a0 100644
--- a/src/command/completion.rs
+++ b/src/command/completion.rs
@@ -64,8 +64,8 @@ impl Completions {
) -> Self {
let completions = wholes.iter()
.map(|w|
- if w.starts_with(start) {
- &w[start.len()..]
+ if let Some(stripped) = w.strip_prefix(start) {
+ stripped
} else {
// this might become a feature but right now it's a bug
warn!("unexpected non completing whole: {:?}", w);
diff --git a/src/command/sequence.rs b/src/command/sequence.rs
index ac064cd..87ee50e 100644
--- a/src/command/sequence.rs
+++ b/src/command/sequence.rs
@@ -26,10 +26,10 @@ impl Sequence {
_ => String::from(";"),
}
}
- pub fn new(raw: String, separator: Option<String>) -> Self {
+ pub fn new<S: Into<String>>(raw: S, separator: Option<S>) -> Self {
Self {
- raw,
- separator: separator.unwrap_or_else(Sequence::local_separator),
+ raw: raw.into(),
+ separator: separator.map_or_else(Sequence::local_separator, |s| s.into()),
}
}
pub fn new_single(cmd: String) -> Self {