pub fn optional(token: Token) -> Token
Expand description
Matches the input with and without the contained token.
ยงExamples
use initiative_core::command::prelude::*;
let token = optional(keyword("badger"));
assert_eq!(
vec![
// Passes the input directly through to the overflow,
FuzzyMatch::Overflow(TokenMatch::from(&token), "badger".into()),
// as well as the matched result if present.
FuzzyMatch::Exact(TokenMatch::new(&token, TokenMatch::from(&keyword("badger")))),
],
token
.match_input("badger", &app_meta)
.collect::<Vec<_>>()
.await,
);