diff --git a/crates/commands/src/commands.rs b/crates/commands/src/commands.rs index 1e9e06e8..b87dc878 100644 --- a/crates/commands/src/commands.rs +++ b/crates/commands/src/commands.rs @@ -18,26 +18,28 @@ pub mod server_config; pub mod switch; pub mod system; +use smol_str::SmolStr; + use crate::{command, token::Token}; #[derive(Clone)] pub struct Command { // TODO: fix hygiene pub tokens: Vec, - pub help: String, - pub cb: String, + pub help: SmolStr, + pub cb: SmolStr, } impl Command { pub fn new( tokens: impl IntoIterator, - help: impl ToString, - cb: impl ToString, + help: impl Into, + cb: impl Into, ) -> Self { Self { tokens: tokens.into_iter().collect(), - help: help.to_string(), - cb: cb.to_string(), + help: help.into(), + cb: cb.into(), } } } diff --git a/crates/commands/src/lib.rs b/crates/commands/src/lib.rs index 4a86d841..4b701e1d 100644 --- a/crates/commands/src/lib.rs +++ b/crates/commands/src/lib.rs @@ -84,7 +84,7 @@ fn parse_command(input: String) -> CommandResult { if let Some(command_ref) = local_tree.current_command_key { return CommandResult::Ok { command: ParsedCommand { - command_ref: command_ref.to_owned(), + command_ref: command_ref.into(), args, flags, }, diff --git a/crates/commands/src/tree.rs b/crates/commands/src/tree.rs index d897dc4f..56c53336 100644 --- a/crates/commands/src/tree.rs +++ b/crates/commands/src/tree.rs @@ -1,9 +1,11 @@ +use smol_str::SmolStr; + use crate::{commands::Command, Token}; use std::{cmp::Ordering, collections::HashMap}; #[derive(Debug, Clone)] pub struct TreeBranch { - pub current_command_key: Option, + pub current_command_key: Option, /// branches.keys(), but sorted by specificity pub possible_tokens: Vec, pub branches: HashMap,