mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-13 17:20:14 +00:00
refactor(commands): remove some unnecessary branching
This commit is contained in:
parent
07b616e422
commit
4f390e2a14
1 changed files with 0 additions and 14 deletions
|
|
@ -246,13 +246,6 @@ fn match_flag<'a>(
|
||||||
possible_flags: impl Iterator<Item = &'a Flag>,
|
possible_flags: impl Iterator<Item = &'a Flag>,
|
||||||
matched_flag: MatchedFlag<'a>,
|
matched_flag: MatchedFlag<'a>,
|
||||||
) -> Option<Result<(SmolStr, Option<Parameter>), (&'a Flag, FlagMatchError)>> {
|
) -> Option<Result<(SmolStr, Option<Parameter>), (&'a Flag, FlagMatchError)>> {
|
||||||
// skip if 0 length (we could just take an array ref here and in next_token aswell but its nice to keep it flexible)
|
|
||||||
if let (_, Some(len)) = possible_flags.size_hint()
|
|
||||||
&& len == 0
|
|
||||||
{
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
|
|
||||||
// check for all (possible) flags, see if token matches
|
// check for all (possible) flags, see if token matches
|
||||||
for flag in possible_flags {
|
for flag in possible_flags {
|
||||||
println!("matching flag {flag:?}");
|
println!("matching flag {flag:?}");
|
||||||
|
|
@ -279,13 +272,6 @@ fn next_token<'a>(
|
||||||
input: &str,
|
input: &str,
|
||||||
current_pos: usize,
|
current_pos: usize,
|
||||||
) -> Option<Result<(&'a Token, Option<TokenMatchValue>, usize), (&'a Token, TokenMatchError)>> {
|
) -> Option<Result<(&'a Token, Option<TokenMatchValue>, usize), (&'a Token, TokenMatchError)>> {
|
||||||
// skip if 0 length
|
|
||||||
if let (_, Some(len)) = possible_tokens.size_hint()
|
|
||||||
&& len == 0
|
|
||||||
{
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get next parameter, matching quotes
|
// get next parameter, matching quotes
|
||||||
let matched = string::next_param(&input, current_pos);
|
let matched = string::next_param(&input, current_pos);
|
||||||
println!("matched: {matched:?}\n---");
|
println!("matched: {matched:?}\n---");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue