From 3689947a2c61c3c6f54e0ee0efb17c6ffd48297c Mon Sep 17 00:00:00 2001 From: GnomedDev Date: Sun, 10 Dec 2023 00:11:33 +0000 Subject: [PATCH] Fix breakage due to FixedString --- Cargo.lock | 102 ++++++++++++---------- examples/feature_showcase/checks.rs | 2 +- examples/feature_showcase/collector.rs | 2 +- examples/feature_showcase/context_menu.rs | 2 +- examples/help_generation/main.rs | 6 +- src/builtins/mod.rs | 2 +- src/builtins/paginate.rs | 4 +- src/dispatch/prefix.rs | 3 +- src/modal.rs | 6 +- src/structs/context.rs | 2 +- 10 files changed, 71 insertions(+), 60 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3bce27ddb476..9214f6f690be 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -194,9 +194,9 @@ dependencies = [ [[package]] name = "core-foundation" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" dependencies = [ "core-foundation-sys", "libc", @@ -204,9 +204,9 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.4" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "cpufeatures" @@ -312,9 +312,9 @@ checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" [[package]] name = "deranged" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f32d04922c60427da6f9fef14d042d9edddef64cb9d4ce0d64d0685fbeb1fd3" +checksum = "8eb30d70a07a3b04884d2677f06bec33509dc67ca60d92949e5535352d3191dc" dependencies = [ "powerfmt", "serde", @@ -637,9 +637,9 @@ dependencies = [ [[package]] name = "http-body" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", "http", @@ -789,9 +789,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "js-sys" @@ -804,15 +804,15 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.150" +version = "0.2.151" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" +checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" [[package]] name = "linux-raw-sys" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829" +checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" [[package]] name = "lock_api" @@ -878,9 +878,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.9" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" +checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" dependencies = [ "libc", "wasi", @@ -917,9 +917,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "parking_lot" @@ -1147,9 +1147,9 @@ dependencies = [ [[package]] name = "ring" -version = "0.17.5" +version = "0.17.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb0205304757e5d899b9c2e448b867ffd03ae7f988002e47cd24954391394d0b" +checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74" dependencies = [ "cc", "getrandom", @@ -1173,22 +1173,22 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustix" -version = "0.38.25" +version = "0.38.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc99bc2d4f1fed22595588a013687477aedf3cdcfb26558c559edb67b4d9b22e" +checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" dependencies = [ "bitflags 2.4.1", "errno", "libc", "linux-raw-sys", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "rustls" -version = "0.21.9" +version = "0.21.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "629648aced5775d558af50b2b4c7b02983a04b312126d45eeead26e7caa498b9" +checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" dependencies = [ "log", "ring", @@ -1217,9 +1217,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.15" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" [[package]] name = "same-file" @@ -1326,7 +1326,7 @@ dependencies = [ [[package]] name = "serenity" version = "0.12.0" -source = "git+https://github.com/serenity-rs/serenity?branch=next#6981848992cb999a5fca4d6a96decad21f821bbf" +source = "git+https://github.com/serenity-rs/serenity?branch=next#9da2a4422685ce152df79d40e8d4b27ea14bba31" dependencies = [ "arrayvec", "async-trait", @@ -1345,6 +1345,7 @@ dependencies = [ "secrecy", "serde", "serde_json", + "small-fixed-array", "time", "tokio", "tokio-tungstenite", @@ -1389,6 +1390,15 @@ dependencies = [ "autocfg", ] +[[package]] +name = "small-fixed-array" +version = "0.1.0" +source = "git+https://github.com/GnomedDev/small-fixed-array#295791a491435a660a5a51164ab4215b605dd49c" +dependencies = [ + "serde", + "tracing", +] + [[package]] name = "smallvec" version = "1.11.2" @@ -1573,9 +1583,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.34.0" +version = "1.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0c014766411e834f7af5b8f4cf46257aab4036ca95e9d2c144a10f59ad6f5b9" +checksum = "841d45b238a16291a4e1584e61820b8ae57d696cc5015c459c229ccc6990cc1c" dependencies = [ "backtrace", "bytes", @@ -1678,15 +1688,15 @@ dependencies = [ [[package]] name = "triomphe" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0c5a71827ac326072b6405552093e2ad2accd25a32fd78d4edc82d98c7f2409" +checksum = "859eb650cfee7434994602c3a68b25d77ad9e68c8a6cd491616ef86661382eb3" [[package]] name = "try-lock" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "tungstenite" @@ -1731,9 +1741,9 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "typesize" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e43a952445d2d9df648a822545093c01699df209ceda4df5ac78fef8969c61c" +checksum = "00d112ab96abcb66808bb508fce8a9143fe2cee32b167d240d5d792c326db5a4" dependencies = [ "chrono", "dashmap", @@ -1749,9 +1759,9 @@ dependencies = [ [[package]] name = "typesize-derive" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5274e4d582fd16b83bf7949cc44d6610d3b0290e441d9e5c337fdda9a003849f" +checksum = "0b122284365ba8497be951b9a21491f70c9688eb6fddc582931a0703f6a00ece" dependencies = [ "proc-macro2", "quote", @@ -1760,18 +1770,18 @@ dependencies = [ [[package]] name = "unic-langid" -version = "0.9.1" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "398f9ad7239db44fd0f80fe068d12ff22d78354080332a5077dc6f52f14dcf2f" +checksum = "887622f8e7b723780c5e64b04dcc0c9b8f426ada7cca6790cd3ea3bf0f08037a" dependencies = [ "unic-langid-impl", ] [[package]] name = "unic-langid-impl" -version = "0.9.1" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e35bfd2f2b8796545b55d7d3fd3e89a0613f68a0d1c8bc28cb7ff96b411a35ff" +checksum = "5adeb847e35eed4efbffd9fb2e4d078b91ece56e4d6a3c0d2df55b3a1dac07d5" dependencies = [ "tinystr", ] @@ -1787,9 +1797,9 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" +checksum = "6f2528f27a9eb2b21e69c95319b30bd0efd85d09c379741b0f78ea1d86be2416" [[package]] name = "unicode-ident" @@ -1942,9 +1952,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.65" +version = "0.3.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5db499c5f66323272151db0e666cd34f78617522fb0c1604d31a27c50c206a85" +checksum = "50c24a44ec86bb68fbecd1b3efed7e85ea5621b39b35ef2766b66cd984f8010f" dependencies = [ "js-sys", "wasm-bindgen", diff --git a/examples/feature_showcase/checks.rs b/examples/feature_showcase/checks.rs index 87adef8be85d..892254c938cc 100644 --- a/examples/feature_showcase/checks.rs +++ b/examples/feature_showcase/checks.rs @@ -49,7 +49,7 @@ async fn is_ferris(ctx: Context<'_>) -> Result { Some(guild_id) => ctx.author().nick_in(ctx, guild_id).await, None => None, }; - let name = nickname.as_ref().unwrap_or(&ctx.author().name); + let name = nickname.as_deref().unwrap_or(&ctx.author().name); Ok(name.eq_ignore_ascii_case("ferris")) } diff --git a/examples/feature_showcase/collector.rs b/examples/feature_showcase/collector.rs index 28c18d012191..9c844a113269 100644 --- a/examples/feature_showcase/collector.rs +++ b/examples/feature_showcase/collector.rs @@ -25,7 +25,7 @@ pub async fn boop(ctx: Context<'_>) -> Result<(), Error> { .author_id(ctx.author().id) .channel_id(ctx.channel_id()) .timeout(std::time::Duration::from_secs(120)) - .filter(move |mci| mci.data.custom_id == uuid_boop.to_string()) + .filter(move |mci| mci.data.custom_id.as_str() == uuid_boop.to_string()) .await { boop_count += 1; diff --git a/examples/feature_showcase/context_menu.rs b/examples/feature_showcase/context_menu.rs index 1d55c52479e0..87143a14fe01 100644 --- a/examples/feature_showcase/context_menu.rs +++ b/examples/feature_showcase/context_menu.rs @@ -23,6 +23,6 @@ pub async fn echo( ctx: Context<'_>, #[description = "Message to echo (enter a link or ID)"] msg: serenity::Message, ) -> Result<(), Error> { - ctx.say(&msg.content).await?; + ctx.say(msg.content).await?; Ok(()) } diff --git a/examples/help_generation/main.rs b/examples/help_generation/main.rs index 756372918930..f1fbe4531b42 100644 --- a/examples/help_generation/main.rs +++ b/examples/help_generation/main.rs @@ -236,7 +236,7 @@ async fn food_react( #[description = "Message to react to (enter a link or ID)"] msg: serenity::Message, ) -> Result<(), Error> { let reaction = FOOD[rand::thread_rng().gen_range(0..FOOD.len())].to_string(); - msg.react(ctx, serenity::ReactionType::Unicode(reaction)) + msg.react(ctx, serenity::ReactionType::Unicode(reaction.into())) .await?; ctx.say("Reacted!").await?; Ok(()) @@ -258,7 +258,7 @@ async fn fruit_react( #[description = "Message to react to (enter a link or ID)"] msg: serenity::Message, ) -> Result<(), Error> { let reaction = FRUIT[rand::thread_rng().gen_range(0..FRUIT.len())].to_string(); - msg.react(ctx, serenity::ReactionType::Unicode(reaction)) + msg.react(ctx, serenity::ReactionType::Unicode(reaction.into())) .await?; ctx.say("Reacted!").await?; Ok(()) @@ -276,7 +276,7 @@ async fn vegetable_react( #[description = "Message to react to (enter a link or ID)"] msg: serenity::Message, ) -> Result<(), Error> { let reaction = VEGETABLES[rand::thread_rng().gen_range(0..VEGETABLES.len())].to_string(); - msg.react(ctx, serenity::ReactionType::Unicode(reaction)) + msg.react(ctx, serenity::ReactionType::Unicode(reaction.into())) .await?; ctx.say("Reacted!").await?; Ok(()) diff --git a/src/builtins/mod.rs b/src/builtins/mod.rs index 718436ab43ee..96bcfb27716c 100644 --- a/src/builtins/mod.rs +++ b/src/builtins/mod.rs @@ -232,7 +232,7 @@ pub async fn servers(ctx: crate::Context<'_, U, E>) -> Result<(), serenity // Aggregate all guilds and sort them by size let mut hidden_guilds = 0; let mut hidden_guilds_members = 0; - let mut shown_guilds = Vec::<(String, u64)>::new(); + let mut shown_guilds = Vec::new(); for guild_id in ctx.cache().guilds() { match ctx.cache().guild(guild_id) { Some(guild) => { diff --git a/src/builtins/paginate.rs b/src/builtins/paginate.rs index 83094be06b58..55da8099f670 100644 --- a/src/builtins/paginate.rs +++ b/src/builtins/paginate.rs @@ -66,12 +66,12 @@ pub async fn paginate( .await { // Depending on which button was pressed, go to next or previous page - if press.data.custom_id == next_button_id { + if press.data.custom_id.as_str() == next_button_id { current_page += 1; if current_page >= pages.len() { current_page = 0; } - } else if press.data.custom_id == prev_button_id { + } else if press.data.custom_id.as_str() == prev_button_id { current_page = current_page.checked_sub(1).unwrap_or(pages.len() - 1); } else { // This is an unrelated button interaction diff --git a/src/dispatch/prefix.rs b/src/dispatch/prefix.rs index aba0177dfee2..79e3005201d2 100644 --- a/src/dispatch/prefix.rs +++ b/src/dispatch/prefix.rs @@ -94,7 +94,8 @@ async fn strip_prefix<'a, U, E>( .strip_prefix(&framework.bot_id.to_string())? .strip_prefix('>') })() { - let mention_prefix = &msg.content[..(msg.content.len() - stripped_content.len())]; + let mention_prefix = + &msg.content[..(msg.content.len() as usize - stripped_content.len())]; return Some((mention_prefix, stripped_content)); } } diff --git a/src/modal.rs b/src/modal.rs index 0ad4c78ac4a5..e24f5cf9afb4 100644 --- a/src/modal.rs +++ b/src/modal.rs @@ -10,7 +10,7 @@ pub fn find_modal_text( data: &mut serenity::ModalInteractionData, custom_id: &str, ) -> Option { - for row in &mut data.components { + for row in data.components.iter_mut() { let text = match row.components.get_mut(0) { Some(serenity::ActionRowComponent::InputText(text)) => text, Some(_) => { @@ -26,7 +26,7 @@ pub fn find_modal_text( if text.custom_id == custom_id { return match std::mem::take(&mut text.value) { Some(val) if val.is_empty() => None, - Some(val) => Some(val), + Some(val) => Some(val.into_string()), None => None, }; } @@ -55,7 +55,7 @@ async fn execute_modal_generic< // Wait for user to submit let response = serenity::collector::ModalInteractionCollector::new(&ctx.shard) - .filter(move |d| d.data.custom_id == modal_custom_id) + .filter(move |d| d.data.custom_id.as_str() == modal_custom_id) .timeout(timeout.unwrap_or(std::time::Duration::from_secs(3600))) .await; let response = match response { diff --git a/src/structs/context.rs b/src/structs/context.rs index 809b8d27e4a8..4464cc8a1bb7 100644 --- a/src/structs/context.rs +++ b/src/structs/context.rs @@ -450,7 +450,7 @@ context_methods! { } string } - Context::Prefix(ctx) => ctx.msg.content.clone(), + Context::Prefix(ctx) => ctx.msg.content.to_string(), } }