Skip to content

Commit 580c6b9

Browse files
committed
Fix clippy
1 parent bf79aa9 commit 580c6b9

File tree

5 files changed

+13
-14
lines changed

5 files changed

+13
-14
lines changed

src/cache/wrappers.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ pub(crate) struct MaybeOwnedArc<T>(
123123
#[cfg(feature = "temp_cache")]
124124
impl<T> MaybeOwnedArc<T> {
125125
pub(crate) fn new(inner: T) -> Self {
126-
Self(Arc::new(inner).into())
126+
Self(Arc::new(inner))
127127
}
128128

129129
pub(crate) fn get_inner(self) -> Arc<T> {
@@ -159,6 +159,6 @@ impl<T> std::ops::Deref for MaybeOwnedArc<T> {
159159
#[cfg(feature = "temp_cache")]
160160
impl<T> Clone for MaybeOwnedArc<T> {
161161
fn clone(&self) -> Self {
162-
Self(self.0.clone().into())
162+
Self(Arc::clone(&self.0))
163163
}
164164
}

src/model/channel/channel_id.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ impl ChannelId {
5555
guild_id: Option<GuildId>,
5656
) -> Result<GuildChannel> {
5757
#[cfg(feature = "cache")]
58-
// Ignore clippy, the two `if let`s must be separated
59-
#[expect(clippy::collapsible_if)]
58+
#[cfg_attr(not(feature = "temp_cache"), expect(clippy::collapsible_if))]
6059
if let Some(cache) = cache_http.cache() {
6160
if let Some(guild_id) = guild_id
6261
&& let Some(guild) = cache.guild(guild_id)

src/model/channel/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ impl Channel {
191191
}
192192

193193
/// If this is a guild channel or guild thread, returns the corresponding guild's Id.
194+
#[must_use]
194195
pub fn guild_id(&self) -> Option<GuildId> {
195196
match self {
196197
Channel::GuildThread(thread) => Some(thread.base.guild_id),

src/model/channel/thread.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ impl ThreadId {
3333
guild_id: Option<GuildId>,
3434
) -> Result<GuildThread> {
3535
#[cfg(feature = "cache")]
36-
// Ignore clippy, the two `if let`s must be separated
37-
#[expect(clippy::collapsible_if)]
36+
#[cfg_attr(not(feature = "temp_cache"), expect(clippy::collapsible_if))]
3837
if let Some(cache) = cache_http.cache() {
3938
if let Some(guild_id) = guild_id
4039
&& let Some(guild) = cache.guild(guild_id)

src/model/user.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -552,10 +552,10 @@ impl UserId {
552552
}
553553

554554
#[cfg(feature = "temp_cache")]
555-
if let Some(cache) = cache_http.cache() {
556-
if let Some(private_channel) = cache.temp_private_channels.get(&self) {
557-
return Ok(PrivateChannel::clone(&private_channel));
558-
}
555+
if let Some(cache) = cache_http.cache()
556+
&& let Some(private_channel) = cache.temp_private_channels.get(&self)
557+
{
558+
return Ok(PrivateChannel::clone(&private_channel));
559559
}
560560

561561
let body = CreateDmChannel {
@@ -641,10 +641,10 @@ impl UserId {
641641
pub async fn to_user(self, cache_http: impl CacheHttp) -> Result<User> {
642642
#[cfg(feature = "temp_cache")]
643643
{
644-
if let Some(cache) = cache_http.cache() {
645-
if let Some(user) = cache.temp_users.get(&self) {
646-
return Ok(User::clone(&user));
647-
}
644+
if let Some(cache) = cache_http.cache()
645+
&& let Some(user) = cache.temp_users.get(&self)
646+
{
647+
return Ok(User::clone(&user));
648648
}
649649
}
650650

0 commit comments

Comments
 (0)