Skip to content

Commit

Permalink
create_application_commands can now take any IntoIterator: not just &[]
Browse files Browse the repository at this point in the history
  • Loading branch information
zkxs committed Aug 12, 2024
1 parent 8401811 commit 28b9b64
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/builtins/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ use crate::serenity_prelude as serenity;
/// serenity::Command::set_global_commands(ctx.http(), &create_commands).await?;
/// # Ok(()) }
/// ```
pub fn create_application_commands<U, E>(
commands: &[crate::Command<U, E>],
) -> Vec<serenity::CreateCommand<'static>> {
pub fn create_application_commands<'a, U:'a , E: 'a>(
commands: impl IntoIterator<Item=&'a crate::Command<U, E>>,
) -> Vec<serenity::CreateCommand> {
/// We decided to extract context menu commands recursively, despite the subcommand hierarchy
/// not being preserved. Because it's more confusing to just silently discard context menu
/// commands if they're not top-level commands.
Expand All @@ -35,7 +35,7 @@ pub fn create_application_commands<U, E>(
}
}

let mut commands_builder = Vec::with_capacity(commands.len());
let mut commands_builder = Vec::new();
for command in commands {
if let Some(slash_command) = command.create_as_slash_command() {
commands_builder.push(slash_command);
Expand Down

0 comments on commit 28b9b64

Please sign in to comment.