Skip to content

Commit

Permalink
Use IndexMap instead of OrderedMap (#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
GnomedDev authored May 27, 2024
1 parent 6ead1e1 commit b17e5ae
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 60 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ tracing = { version = "0.1.40", features = ["log"] } # warning about weird state
derivative = "2.2.0"
parking_lot = "0.12.1"
trim-in-place = "0.1.7"
indexmap = "2.2.6"

[dependencies.serenity]
default-features = false
Expand Down
5 changes: 3 additions & 2 deletions src/builtins/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,11 @@ async fn generate_all_commands<U, E>(
ctx: crate::Context<'_, U, E>,
config: &HelpConfiguration<'_>,
) -> Result<String, serenity::Error> {
let mut categories = crate::util::OrderedMap::<Option<&str>, Vec<&crate::Command<U, E>>>::new();
let mut categories = indexmap::IndexMap::<Option<&str>, Vec<&crate::Command<U, E>>>::new();
for cmd in &ctx.framework().options().commands {
categories
.get_or_insert_with(cmd.category.as_deref(), Vec::new)
.entry(cmd.category.as_deref())
.or_default()
.push(cmd);
}

Expand Down
5 changes: 3 additions & 2 deletions src/builtins/pretty_help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,18 @@ async fn pretty_help_all_commands<U, E>(
ctx: crate::Context<'_, U, E>,
config: PrettyHelpConfiguration<'_>,
) -> Result<(), serenity::Error> {
let mut categories = crate::util::OrderedMap::new();
let commands = ctx.framework().options().commands.iter().filter(|cmd| {
!cmd.hide_in_help
&& (cmd.prefix_action.is_some()
|| cmd.slash_action.is_some()
|| (cmd.context_menu_action.is_some() && config.show_context_menu_commands))
});

let mut categories = indexmap::IndexMap::<Option<&str>, Vec<&crate::Command<U, E>>>::new();
for cmd in commands {
categories
.get_or_insert_with(cmd.category.as_deref(), Vec::new)
.entry(cmd.category.as_deref())
.or_default()
.push(cmd);
}

Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,6 @@ pub mod reply;
pub mod slash_argument;
pub mod structs;
pub mod track_edits;
mod util;
pub mod macros {
//! Procedural macros used in poise, like [`command`]
#[doc(inline)]
Expand Down
55 changes: 0 additions & 55 deletions src/util.rs

This file was deleted.

0 comments on commit b17e5ae

Please sign in to comment.