Skip to content

Commit 47a5118

Browse files
committed
use indexmap for help menu
1 parent c1d0c3e commit 47a5118

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ lazy_static = "1.4.0"
1818
log = "0.4.0"
1919
env_logger = "0.7.1"
2020
envy = "0.4"
21+
indexmap = "1.3"

src/commands.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use crate::{
22
api,
33
state_machine::{CharacterSet, StateMachine},
44
};
5+
use indexmap::IndexMap;
56
use reqwest::blocking::Client as HttpClient;
67
use serenity::{model::channel::Message, prelude::Context};
78
use std::{collections::HashMap, sync::Arc};
@@ -35,15 +36,15 @@ pub struct Args<'m> {
3536
pub(crate) struct Commands {
3637
state_machine: StateMachine<Arc<Command>>,
3738
client: HttpClient,
38-
menu: Option<HashMap<&'static str, (&'static str, GuardFn)>>,
39+
menu: Option<IndexMap<&'static str, (&'static str, GuardFn)>>,
3940
}
4041

4142
impl Commands {
4243
pub(crate) fn new() -> Self {
4344
Self {
4445
state_machine: StateMachine::new(),
4546
client: HttpClient::new(),
46-
menu: Some(HashMap::new()),
47+
menu: Some(IndexMap::new()),
4748
}
4849
}
4950

@@ -168,7 +169,7 @@ impl Commands {
168169
);
169170
}
170171

171-
pub(crate) fn menu(&mut self) -> Option<HashMap<&'static str, (&'static str, GuardFn)>> {
172+
pub(crate) fn menu(&mut self) -> Option<IndexMap<&'static str, (&'static str, GuardFn)>> {
172173
self.menu.take()
173174
}
174175

src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use diesel::prelude::*;
2525
use envy;
2626
use serde::Deserialize;
2727
use serenity::{model::prelude::*, prelude::*};
28-
use std::collections::HashMap;
28+
use indexmap::IndexMap;
2929

3030
#[derive(Deserialize)]
3131
struct Config {
@@ -192,7 +192,7 @@ fn app() -> Result<()> {
192192
Ok(())
193193
}
194194

195-
fn main_menu(args: &Args, commands: &HashMap<&str, (&str, GuardFn)>) -> String {
195+
fn main_menu(args: &Args, commands: &IndexMap<&str, (&str, GuardFn)>) -> String {
196196
let mut menu = format!("Commands:\n");
197197

198198
menu = commands

0 commit comments

Comments
 (0)