diff --git a/Cargo.toml b/Cargo.toml index 39a2096e381..9740988c000 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,4 +22,4 @@ edition = "2021" include = ["src/**/*.rs", "README.md"] license = "ISC" repository = "https://github.com/twilight-rs/twilight.git" -rust-version = "1.67" +rust-version = "1.79" diff --git a/README.md b/README.md index e78d1d5cc82..867c7ac1374 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ functionality. Please use the individual crates listed below instead! ## Installation -Twilight supports a MSRV of Rust 1.67. +Twilight supports a MSRV of Rust 1.79. We recommend that most users start out with these crates: @@ -98,9 +98,9 @@ Utility crate that adds utilities to the twilight ecosystem that do not fit in any other crate. Currently, it contains: - A trait to make extracting data from Discord identifiers (Snowflakes) -easier; + easier; - A calculator to calculate the permissions of a member in a guild or -channel. + channel. ### [`twilight-gateway-queue`] @@ -201,7 +201,7 @@ All first-party crates are licensed under [ISC][LICENSE.md] [license badge]: https://img.shields.io/badge/license-ISC-blue.svg?style=for-the-badge&logo=pastebin [license link]: https://github.com/twilight-rs/twilight/blob/main/LICENSE.md [logo]: https://raw.githubusercontent.com/twilight-rs/twilight/main/logo.png -[rust badge]: https://img.shields.io/badge/rust-1.67+-93450a.svg?style=for-the-badge&logo=rust +[rust badge]: https://img.shields.io/badge/rust-1.79+-93450a.svg?style=for-the-badge&logo=rust [`twilight-cache-inmemory`]: https://twilight.rs/chapter_1_crates/section_4_cache_inmemory.html [`twilight-gateway-queue`]: https://twilight.rs/chapter_1_crates/section_7_first_party/section_5_gateway_queue.html [`twilight-gateway`]: https://twilight.rs/chapter_1_crates/section_3_gateway.html diff --git a/book/src/versions/0.15/2023-09-10.md b/book/src/versions/0.15/2023-09-10.md index 4d159abf5aa..b1a276af65a 100644 --- a/book/src/versions/0.15/2023-09-10.md +++ b/book/src/versions/0.15/2023-09-10.md @@ -83,7 +83,7 @@ twilight-model no longer depends on `tracing`. ## MSRV -All twilight ecosystem crates now target a MSRV of rustc 1.67. This was necessary +All twilight ecosystem crates now target a MSRV of rustc 1.79. This was necessary due to MSRV increases in our dependencies. ## Performance Improvements diff --git a/twilight-cache-inmemory/README.md b/twilight-cache-inmemory/README.md index 7a283b20308..4969dd5d868 100644 --- a/twilight-cache-inmemory/README.md +++ b/twilight-cache-inmemory/README.md @@ -77,4 +77,4 @@ All first-party crates are licensed under [ISC][LICENSE.md] [github link]: https://github.com/twilight-rs/twilight [license badge]: https://img.shields.io/badge/license-ISC-blue.svg?style=for-the-badge&logo=pastebin [license link]: https://github.com/twilight-rs/twilight/blob/main/LICENSE.md -[rust badge]: https://img.shields.io/badge/rust-1.67+-93450a.svg?style=for-the-badge&logo=rust +[rust badge]: https://img.shields.io/badge/rust-1.79+-93450a.svg?style=for-the-badge&logo=rust diff --git a/twilight-cache-inmemory/src/event/reaction.rs b/twilight-cache-inmemory/src/event/reaction.rs index 1d456b13c75..e2b113fada4 100644 --- a/twilight-cache-inmemory/src/event/reaction.rs +++ b/twilight-cache-inmemory/src/event/reaction.rs @@ -39,8 +39,7 @@ impl UpdateCache for ReactionAdd { } else { let me = cache .current_user() - .map(|user| user.id() == self.0.user_id) - .unwrap_or_default(); + .is_some_and(|user| user.id() == self.0.user_id); message.add_reaction(Reaction { burst_colors: Vec::new(), diff --git a/twilight-cache-inmemory/src/event/sticker.rs b/twilight-cache-inmemory/src/event/sticker.rs index 28b3ce23038..58e6d2ff37e 100644 --- a/twilight-cache-inmemory/src/event/sticker.rs +++ b/twilight-cache-inmemory/src/event/sticker.rs @@ -112,13 +112,11 @@ mod tests { assert!(cache .stickers .get(&STICKER_ONE_ID) - .map(|r| r.id == STICKER_ONE_ID) - .unwrap_or_default()); + .is_some_and(|r| r.id == STICKER_ONE_ID)); assert!(cache .stickers .get(&STICKER_TWO_ID) - .map(|r| r.id == STICKER_TWO_ID) - .unwrap_or_default()); + .is_some_and(|r| r.id == STICKER_TWO_ID)); let guild_stickers = cache .guild_stickers @@ -145,8 +143,7 @@ mod tests { assert!(cache .stickers .get(&STICKER_ONE_ID) - .map(|r| r.id == STICKER_ONE_ID) - .unwrap_or_default()); + .is_some_and(|r| r.id == STICKER_ONE_ID)); let guild_stickers = cache .guild_stickers .get(&GUILD_ID) diff --git a/twilight-cache-inmemory/src/event/voice_state.rs b/twilight-cache-inmemory/src/event/voice_state.rs index 31e19a7f7b4..36b6804e583 100644 --- a/twilight-cache-inmemory/src/event/voice_state.rs +++ b/twilight-cache-inmemory/src/event/voice_state.rs @@ -23,12 +23,11 @@ impl InMemoryCache { let remove_channel_mapping = self .voice_state_channels .get_mut(&voice_state.channel_id()) - .map(|mut channel_voice_states| { + .is_some_and(|mut channel_voice_states| { channel_voice_states.remove(&(guild_id, user_id)); channel_voice_states.is_empty() - }) - .unwrap_or_default(); + }); if remove_channel_mapping { self.voice_state_channels.remove(&voice_state.channel_id()); @@ -54,15 +53,14 @@ impl InMemoryCache { } else { // voice channel_id does not exist, signifying that the user has left { - let remove_guild = self - .voice_state_guilds - .get_mut(&guild_id) - .map(|mut guild_users| { - guild_users.remove(&user_id); - - guild_users.is_empty() - }) - .unwrap_or_default(); + let remove_guild = + self.voice_state_guilds + .get_mut(&guild_id) + .is_some_and(|mut guild_users| { + guild_users.remove(&user_id); + + guild_users.is_empty() + }); if remove_guild { self.voice_state_guilds.remove(&guild_id); diff --git a/twilight-cache-inmemory/src/permission.rs b/twilight-cache-inmemory/src/permission.rs index 6111745896e..9747e65cc00 100644 --- a/twilight-cache-inmemory/src/permission.rs +++ b/twilight-cache-inmemory/src/permission.rs @@ -562,8 +562,7 @@ impl<'a, CacheModels: CacheableModels> InMemoryCachePermissions<'a, CacheModels> self.cache .guilds .get(&guild_id) - .map(|r| r.owner_id() == user_id) - .unwrap_or_default() + .is_some_and(|r| r.owner_id() == user_id) } /// Retrieve a member's roles' permissions and the guild's `@everyone` @@ -1045,8 +1044,8 @@ mod tests { /// In particular, we want to test that: /// /// - if a member is timed out they will be limited to the intersection of - /// the [`Permissions::READ_MESSAGE_HISTORY`] and - /// [`Permissions::VIEW_CHANNEL`] permissions on a [guild level][`root`] + /// the [`Permissions::READ_MESSAGE_HISTORY`] and + /// [`Permissions::VIEW_CHANNEL`] permissions on a [guild level][`root`] /// - the same is true on a [channel level][`in_channel`] /// - administrators are never timed out /// - checking whether the member's communication is disabled is configurable diff --git a/twilight-gateway-queue/README.md b/twilight-gateway-queue/README.md index 4d604ef8065..f1382ce9d40 100644 --- a/twilight-gateway-queue/README.md +++ b/twilight-gateway-queue/README.md @@ -28,4 +28,4 @@ a HTTP client and server implementation, respectively. [github link]: https://github.com/twilight-rs/twilight [license badge]: https://img.shields.io/badge/license-ISC-blue.svg?style=for-the-badge&logo=pastebin [license link]: https://github.com/twilight-rs/twilight/blob/main/LICENSE.md -[rust badge]: https://img.shields.io/badge/rust-1.67+-93450a.svg?style=for-the-badge&logo=rust +[rust badge]: https://img.shields.io/badge/rust-1.79+-93450a.svg?style=for-the-badge&logo=rust diff --git a/twilight-gateway/README.md b/twilight-gateway/README.md index 1143e9dca0a..111a401b7f6 100644 --- a/twilight-gateway/README.md +++ b/twilight-gateway/README.md @@ -120,4 +120,4 @@ There are a few additional examples located in the [github link]: https://github.com/twilight-rs/twilight [license badge]: https://img.shields.io/badge/license-ISC-blue.svg?style=for-the-badge&logo=pastebin [license link]: https://github.com/twilight-rs/twilight/blob/main/LICENSE.md -[rust badge]: https://img.shields.io/badge/rust-1.67+-93450a.svg?style=for-the-badge&logo=rust +[rust badge]: https://img.shields.io/badge/rust-1.79+-93450a.svg?style=for-the-badge&logo=rust diff --git a/twilight-http-ratelimiting/src/in_memory/bucket.rs b/twilight-http-ratelimiting/src/in_memory/bucket.rs index 08fcf2e6093..f02041d7a0e 100644 --- a/twilight-http-ratelimiting/src/in_memory/bucket.rs +++ b/twilight-http-ratelimiting/src/in_memory/bucket.rs @@ -199,7 +199,7 @@ impl BucketQueueTask { const WAIT: Duration = Duration::from_secs(10); /// Create a new task to manage the ratelimit for a [`Bucket`]. - pub fn new( + pub const fn new( bucket: Arc, buckets: Arc>>>, global: Arc, diff --git a/twilight-http/README.md b/twilight-http/README.md index d05522da680..71326e04f8b 100644 --- a/twilight-http/README.md +++ b/twilight-http/README.md @@ -107,4 +107,4 @@ DNS resolver on the application level. [github link]: https://github.com/twilight-rs/twilight [license badge]: https://img.shields.io/badge/license-ISC-blue.svg?style=for-the-badge&logo=pastebin [license link]: https://github.com/twilight-rs/twilight/blob/main/LICENSE.md -[rust badge]: https://img.shields.io/badge/rust-1.67+-93450a.svg?style=for-the-badge&logo=rust +[rust badge]: https://img.shields.io/badge/rust-1.79+-93450a.svg?style=for-the-badge&logo=rust diff --git a/twilight-http/src/request/guild/user/update_current_user_voice_state.rs b/twilight-http/src/request/guild/user/update_current_user_voice_state.rs index 59c554be58f..1584ae37b00 100644 --- a/twilight-http/src/request/guild/user/update_current_user_voice_state.rs +++ b/twilight-http/src/request/guild/user/update_current_user_voice_state.rs @@ -62,7 +62,7 @@ impl<'a> UpdateCurrentUserVoiceState<'a> { /// # Caveats /// /// - You are able to set `request_to_speak_timestamp` to any present or - /// future time. + /// future time. pub const fn request_to_speak_timestamp(mut self, request_to_speak_timestamp: &'a str) -> Self { if request_to_speak_timestamp.is_empty() { self.fields.request_to_speak_timestamp = Some(Nullable(None)); @@ -79,7 +79,7 @@ impl<'a> UpdateCurrentUserVoiceState<'a> { /// # Caveats /// /// - You must have the `MUTE_MEMBERS` permission to unsuppress yourself. - /// You can always suppress yourself. + /// - You can always suppress yourself. pub const fn suppress(mut self) -> Self { self.fields.suppress = Some(true); diff --git a/twilight-http/src/request/guild/user/update_user_voice_state.rs b/twilight-http/src/request/guild/user/update_user_voice_state.rs index d0ed4e2d4b4..fcfad66c8c9 100644 --- a/twilight-http/src/request/guild/user/update_user_voice_state.rs +++ b/twilight-http/src/request/guild/user/update_user_voice_state.rs @@ -52,10 +52,10 @@ impl<'a> UpdateUserVoiceState<'a> { /// /// - You must have the [`MUTE_MEMBERS`] permission to use this method. /// - When unsuppressed, non-bot users will have their - /// `request_to_speak_timestamp` set to the current time. Bot users will - /// not. + /// `request_to_speak_timestamp` set to the current time. Bot users will + /// not. /// - When suppressed, the user will have their `request_to_speak_timestamp` - /// removed. + /// removed. /// /// [`MUTE_MEMBERS`]: twilight_model::guild::Permissions::MUTE_MEMBERS pub const fn suppress(mut self) -> Self { diff --git a/twilight-lavalink/README.md b/twilight-lavalink/README.md index 3e6adec2d10..3800e077ba9 100644 --- a/twilight-lavalink/README.md +++ b/twilight-lavalink/README.md @@ -121,4 +121,4 @@ There is also an example of a basic bot located in the [root of the [license link]: https://github.com/twilight-rs/twilight/blob/main/LICENSE.md [node]: Node [process]: Lavalink::process -[rust badge]: https://img.shields.io/badge/rust-1.67+-93450a.svg?style=for-the-badge&logo=rust +[rust badge]: https://img.shields.io/badge/rust-1.79+-93450a.svg?style=for-the-badge&logo=rust diff --git a/twilight-mention/README.md b/twilight-mention/README.md index 2bd3fe39a62..ab3609a39af 100644 --- a/twilight-mention/README.md +++ b/twilight-mention/README.md @@ -29,4 +29,4 @@ let message = format!("Hey there, {}!", user_id.mention()); [github link]: https://github.com/twilight-rs/twilight [license badge]: https://img.shields.io/badge/license-ISC-blue.svg?style=for-the-badge&logo=pastebin [license link]: https://github.com/twilight-rs/twilight/blob/main/LICENSE.md -[rust badge]: https://img.shields.io/badge/rust-1.67+-93450a.svg?style=for-the-badge&logo=rust +[rust badge]: https://img.shields.io/badge/rust-1.79+-93450a.svg?style=for-the-badge&logo=rust diff --git a/twilight-model/README.md b/twilight-model/README.md index 90c6dba9c3a..a7de151f292 100644 --- a/twilight-model/README.md +++ b/twilight-model/README.md @@ -39,4 +39,4 @@ Some models have associated builders, which can be found in the [github link]: https://github.com/twilight-rs/twilight [license badge]: https://img.shields.io/badge/license-ISC-blue.svg?style=for-the-badge&logo=pastebin [license link]: https://github.com/twilight-rs/twilight/blob/main/LICENSE.md -[rust badge]: https://img.shields.io/badge/rust-1.67+-93450a.svg?style=for-the-badge&logo=rust +[rust badge]: https://img.shields.io/badge/rust-1.79+-93450a.svg?style=for-the-badge&logo=rust diff --git a/twilight-model/src/gateway/payload/outgoing/request_guild_members.rs b/twilight-model/src/gateway/payload/outgoing/request_guild_members.rs index aae236f9e7e..57609628d1c 100644 --- a/twilight-model/src/gateway/payload/outgoing/request_guild_members.rs +++ b/twilight-model/src/gateway/payload/outgoing/request_guild_members.rs @@ -39,7 +39,7 @@ impl UserIdsError { (self.kind, None) } - fn too_many(ids: Vec>) -> Self { + const fn too_many(ids: Vec>) -> Self { Self { kind: UserIdsErrorType::TooMany { ids }, } diff --git a/twilight-model/src/id/mod.rs b/twilight-model/src/id/mod.rs index 2d0ecb438c7..73454e39743 100644 --- a/twilight-model/src/id/mod.rs +++ b/twilight-model/src/id/mod.rs @@ -354,17 +354,13 @@ impl PartialEq for Id { impl PartialEq for Id { fn eq(&self, other: &i64) -> bool { - u64::try_from(*other) - .map(|v| v == self.value.get()) - .unwrap_or_default() + u64::try_from(*other).is_ok_and(|v| v == self.value.get()) } } impl PartialEq> for i64 { fn eq(&self, other: &Id) -> bool { - u64::try_from(*self) - .map(|v| v == other.value.get()) - .unwrap_or_default() + u64::try_from(*self).is_ok_and(|v| v == other.value.get()) } } diff --git a/twilight-standby/README.md b/twilight-standby/README.md index 524176c9c3d..77db25d5a6d 100644 --- a/twilight-standby/README.md +++ b/twilight-standby/README.md @@ -139,4 +139,4 @@ For more examples, check out each of the methods on [`Standby`]. [github link]: https://github.com/twilight-rs/twilight [license badge]: https://img.shields.io/badge/license-ISC-blue.svg?style=for-the-badge&logo=pastebin [license link]: https://github.com/twilight-rs/twilight/blob/main/LICENSE.md -[rust badge]: https://img.shields.io/badge/rust-1.67+-93450a.svg?style=for-the-badge&logo=rust +[rust badge]: https://img.shields.io/badge/rust-1.79+-93450a.svg?style=for-the-badge&logo=rust diff --git a/twilight-util/README.md b/twilight-util/README.md index bd97fb63225..7c68392a47d 100644 --- a/twilight-util/README.md +++ b/twilight-util/README.md @@ -35,5 +35,5 @@ structured information from [Discord snowflakes]. [github link]: https://github.com/twilight-rs/twilight [license badge]: https://img.shields.io/badge/license-ISC-blue.svg?style=for-the-badge&logo=pastebin [license link]: https://github.com/twilight-rs/twilight/blob/main/LICENSE.md -[rust badge]: https://img.shields.io/badge/rust-1.67+-93450a.svg?style=for-the-badge&logo=rust +[rust badge]: https://img.shields.io/badge/rust-1.79+-93450a.svg?style=for-the-badge&logo=rust [Discord snowflakes]: https://discord.com/developers/docs/reference#snowflakes diff --git a/twilight-util/src/link/webhook.rs b/twilight-util/src/link/webhook.rs index bdceaf2f9a0..c20364f985c 100644 --- a/twilight-util/src/link/webhook.rs +++ b/twilight-util/src/link/webhook.rs @@ -149,7 +149,7 @@ pub fn parse(url: &str) -> Result<(Id, Option<&str>), WebhookPars let mut token = segments.next(); // Don't return an empty token if the segment is empty. - if token.map(str::is_empty).unwrap_or_default() { + if token.is_some_and(str::is_empty) { token = None; } diff --git a/twilight-util/src/permission_calculator/mod.rs b/twilight-util/src/permission_calculator/mod.rs index b1a824dddb9..d74e17c8f6e 100644 --- a/twilight-util/src/permission_calculator/mod.rs +++ b/twilight-util/src/permission_calculator/mod.rs @@ -16,7 +16,7 @@ //! like: //! //! - `@everyone` role is allowed the [Embed Links] and [Add Reactions] -//! permissions; and +//! permissions; and //! - member is denied the [Send Messages] permission. //! //! Taking into account the guild root-level permissions and the permission @@ -230,11 +230,11 @@ impl<'a> PermissionCalculator<'a> { /// circumstances: /// /// - When the permission is denied on the role level and - /// isn't enabled on a role or member permission overwrite; + /// isn't enabled on a role or member permission overwrite; /// - When the permission is denied on a role permission overwrite but isn't - /// enabled on a member permission overwrite; or + /// enabled on a member permission overwrite; or /// - When permission isn't enabled on a guild level and isn't enabled via a - /// permission overwrite. + /// permission overwrite. /// /// When the [Send Messages] permission is denied and is not similarly /// enabled like above then the [Attach Files], [Embed Links], diff --git a/twilight-validate/README.md b/twilight-validate/README.md index e42229f51c7..f48c1349322 100644 --- a/twilight-validate/README.md +++ b/twilight-validate/README.md @@ -19,4 +19,4 @@ manually validating any models from [`twilight-model`]. [github link]: https://github.com/twilight-rs/twilight [license badge]: https://img.shields.io/badge/license-ISC-blue.svg?style=for-the-badge&logo=pastebin [license link]: https://github.com/twilight-rs/twilight/blob/main/LICENSE.md -[rust badge]: https://img.shields.io/badge/rust-1.67+-93450a.svg?style=for-the-badge&logo=rust +[rust badge]: https://img.shields.io/badge/rust-1.79+-93450a.svg?style=for-the-badge&logo=rust