diff --git a/Cargo.toml b/Cargo.toml index c6c1ae8..a21821b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ all-features = true default = [] testing = [ "async", - "async-mutex", + "async-lock", ] async = [ @@ -82,7 +82,7 @@ tokio-openssl = { version = "0.6", optional = true } openssl = { version = "0.10", optional = true, features = ["v110"] } # for some test utilities -async-mutex = { version = "1.4", optional = true } +async-lock = { version = "3.4", optional = true } [dev-dependencies] diff --git a/src/irc.rs b/src/irc.rs index df7282f..8abf34f 100644 --- a/src/irc.rs +++ b/src/irc.rs @@ -94,7 +94,7 @@ pub fn parse_one(input: &str) -> Result<(usize, IrcMessage<'_>), MessageError> { let next = &input[..pos]; let done = next.len() == input.len(); - let msg = IrcMessage::parse(crate::MaybeOwned::Borrowed(next))?; + let msg = IrcMessage::parse(MaybeOwned::Borrowed(next))?; Ok((if done { 0 } else { pos }, msg)) } diff --git a/src/irc/message.rs b/src/irc/message.rs index 9f7531a..6ef4361 100644 --- a/src/irc/message.rs +++ b/src/irc/message.rs @@ -30,7 +30,7 @@ impl<'a> IrcMessage<'a> { let data = data.trim(); if data.is_empty() { - return Err(super::MessageError::EmptyMessage); + return Err(MessageError::EmptyMessage); } let mut p = Parser { @@ -51,7 +51,7 @@ impl<'a> IrcMessage<'a> { /// Get the raw string pub fn get_raw(&self) -> &str { - &*self.raw + &self.raw } /// Get the raw tags diff --git a/src/irc/parser.rs b/src/irc/parser.rs index be1c6b4..dee801d 100644 --- a/src/irc/parser.rs +++ b/src/irc/parser.rs @@ -45,7 +45,7 @@ impl<'a> Parser<'a> { pub(super) fn command(&mut self) -> MaybeOwnedIndex { let input = &self.input[self.pos..]; - let pos = input.find(' ').unwrap_or_else(|| input.len()); + let pos = input.find(' ').unwrap_or(input.len()); self.mark_index(pos, pos + 1) } @@ -55,7 +55,7 @@ impl<'a> Parser<'a> { } let input = self.input.get(self.pos..)?; - let pos = input.find(" :").unwrap_or_else(|| input.len()); + let pos = input.find(" :").unwrap_or(input.len()); Some(self.mark_index(pos, pos)) } diff --git a/src/irc/tags.rs b/src/irc/tags.rs index 9280101..781e732 100644 --- a/src/irc/tags.rs +++ b/src/irc/tags.rs @@ -26,7 +26,7 @@ impl<'a> Tags<'a> { /// Gets the raw string that represents the tags pub fn raw_tags(&self) -> &'a str { - &*self.data + self.data } /// Returns how many tags were parsed @@ -305,14 +305,14 @@ mod tests { #[test] fn round_trip_escape() { let s = r"foo;bar and\foo\rwith\n"; - assert_eq!(unescape_str(&*escape_str(s)), s); + assert_eq!(unescape_str(&escape_str(s)), s); } #[test] fn escaped_tag() { let s = escape_str(r"@hello;world=abc\ndef"); - let data = MaybeOwned::Borrowed(&*s); - let indices = TagIndices::build_indices(&*data).unwrap(); + let data = MaybeOwned::Borrowed(&s); + let indices = TagIndices::build_indices(&data).unwrap(); let tags = Tags::from_data_indices(&data, &indices); assert_eq!(tags.get_unescaped("hello;world").unwrap(), r"abc\ndef"); @@ -322,7 +322,7 @@ mod tests { #[test] fn invalid_input_missing_leading_at() { let data = MaybeOwned::Borrowed("foo=bar;baz=quux"); - let indices = TagIndices::build_indices(&*data).unwrap(); + let indices = TagIndices::build_indices(&data).unwrap(); let tags = Tags::from_data_indices(&data, &indices); assert!(tags.is_empty()); @@ -333,8 +333,8 @@ mod tests { let inputs = &["@", ""]; for input in inputs { - let data = MaybeOwned::Borrowed(*input); - let indices = TagIndices::build_indices(&*data).unwrap(); + let data = MaybeOwned::Borrowed(input); + let indices = TagIndices::build_indices(&data).unwrap(); let tags = Tags::from_data_indices(&data, &indices); assert!(tags.is_empty()); @@ -344,7 +344,7 @@ mod tests { #[test] fn get_parsed() { let input = MaybeOwned::Borrowed("@foo=42;badges=broadcaster/1,subscriber/6"); - let indices = TagIndices::build_indices(&*input).unwrap(); + let indices = TagIndices::build_indices(&input).unwrap(); let tags = Tags::from_data_indices(&input, &indices); assert_eq!(tags.get_parsed::<_, usize>("foo").unwrap(), 42); @@ -379,7 +379,7 @@ mod tests { #[test] fn get_bool() { let input = MaybeOwned::Borrowed("@foo=42;ok=true;nope=false"); - let indices = TagIndices::build_indices(&*input).unwrap(); + let indices = TagIndices::build_indices(&input).unwrap(); let tags = Tags::from_data_indices(&input, &indices); assert!(!tags.get_as_bool("foo")); @@ -397,8 +397,8 @@ mod tests { ]; for input in inputs { - let data = MaybeOwned::Borrowed(*input); - let indices = TagIndices::build_indices(&*data).unwrap(); + let data = MaybeOwned::Borrowed(input); + let indices = TagIndices::build_indices(&data).unwrap(); let tags = Tags::from_data_indices(&data, &indices); assert_eq!(tags.get("foo").unwrap(), "bar"); @@ -417,8 +417,8 @@ mod tests { ]; for input in inputs { - let data = MaybeOwned::Borrowed(*input); - let indices = TagIndices::build_indices(&*data).unwrap(); + let data = MaybeOwned::Borrowed(input); + let indices = TagIndices::build_indices(&data).unwrap(); let tags = Tags::from_data_indices(&data, &indices); let len = tags.into_iter().count(); @@ -477,7 +477,7 @@ mod tests { ]; let input = MaybeOwned::Borrowed(input); - let indices = TagIndices::build_indices(&*input).unwrap(); + let indices = TagIndices::build_indices(&input).unwrap(); let tags = Tags::from_data_indices(&input, &indices); diff --git a/src/maybe_owned/mod.rs b/src/maybe_owned/mod.rs index a2674a4..65a167b 100644 --- a/src/maybe_owned/mod.rs +++ b/src/maybe_owned/mod.rs @@ -74,7 +74,7 @@ impl<'a> PartialEq<&str> for MaybeOwned<'a> { impl<'a> AsRef for MaybeOwned<'a> { fn as_ref(&self) -> &str { match self { - MaybeOwned::Owned(s) => &*s, + MaybeOwned::Owned(s) => s, MaybeOwned::Borrowed(s) => s, } } diff --git a/src/messages/cap.rs b/src/messages/cap.rs index b8f5c2e..97858a8 100644 --- a/src/messages/cap.rs +++ b/src/messages/cap.rs @@ -92,7 +92,7 @@ mod tests { ]; for (msg, expected) in parse(input).map(|s| s.unwrap()).zip(expected) { let msg = Cap::from_irc(msg).unwrap(); - assert_eq!(msg.capability(), Capability::Acknowledged(*expected)); + assert_eq!(msg.capability(), Capability::Acknowledged(expected)); } } diff --git a/src/messages/global_user_state.rs b/src/messages/global_user_state.rs index 478c311..350737d 100644 --- a/src/messages/global_user_state.rs +++ b/src/messages/global_user_state.rs @@ -171,7 +171,7 @@ mod tests { let msg = GlobalUserState::from_irc(msg).unwrap(); assert!(msg.user_id().is_none()); assert!(msg.display_name().is_none()); - assert_eq!(msg.color(), crate::twitch::Color::default()); + assert_eq!(msg.color(), Color::default()); assert_eq!(msg.emote_sets(), vec!["0"]); } } @@ -183,7 +183,7 @@ mod tests { let msg = GlobalUserState::from_irc(msg).unwrap(); assert_eq!(msg.user_id().unwrap(), "241015868"); assert_eq!(msg.display_name().unwrap(), "shaken_bot"); - assert_eq!(msg.color(), crate::twitch::Color::default()); + assert_eq!(msg.color(), Color::default()); assert_eq!(msg.emote_sets(), vec!["0"]); } } diff --git a/src/messages/user_notice.rs b/src/messages/user_notice.rs index 4fe9675..1a23645 100644 --- a/src/messages/user_notice.rs +++ b/src/messages/user_notice.rs @@ -395,7 +395,7 @@ mod tests { for msg in parse(input).map(|s| s.unwrap()) { let msg = UserNotice::from_irc(msg).unwrap(); assert_eq!(msg.channel(), "#giantwaffle"); - assert_eq!(msg.tags().is_empty(), false); + assert!(!msg.tags().is_empty()); } } } diff --git a/src/runner/identity.rs b/src/runner/identity.rs index 870ecd3..2b82654 100644 --- a/src/runner/identity.rs +++ b/src/runner/identity.rs @@ -46,7 +46,7 @@ impl Identity { let (nick, _) = crate::ANONYMOUS_LOGIN; match self { Self::Anonymous { .. } => nick, - Self::Basic { name, .. } | Self::Full { name, .. } => &*name, + Self::Basic { name, .. } | Self::Full { name, .. } => name, } } } diff --git a/src/test/conn.rs b/src/test/conn.rs index 80a4dd0..086583a 100644 --- a/src/test/conn.rs +++ b/src/test/conn.rs @@ -6,7 +6,7 @@ use std::{ task::{Context, Poll}, }; -use async_mutex::Mutex; +use async_lock::Mutex; use futures_lite::io::*; use crate::connector::Connector; diff --git a/src/test/tags_builder.rs b/src/test/tags_builder.rs index bd93159..d167302 100644 --- a/src/test/tags_builder.rs +++ b/src/test/tags_builder.rs @@ -183,7 +183,7 @@ mod tests { (r"the_win_end\r", r"the_win_end\\r"), ]; for (input, expected) in tests { - assert_eq!(tags::escape_str(*input), *expected) + assert_eq!(tags::escape_str(input), *expected) } let tests = &["dont_escape+me", "foo=1234"]; @@ -236,7 +236,7 @@ mod tests { use crate::FromIrcMessage as _; let msg = "@badge-info=;badges=broadcaster/1;color=#FF69B4;display-name=museun;emote-only=1;emotes=25:0-4,6-10/81274:12-17;flags=;id=4e160a53-5482-4764-ba28-f224cd59a51f;mod=0;room-id=23196011;subscriber=0;tmi-sent-ts=1601079032426;turbo=0;user-id=23196011;user-type= :museun!museun@museun.tmi.twitch.tv PRIVMSG #museun :Kappa Kappa VoHiYo\r\n"; - let msg = crate::IrcMessage::parse(crate::MaybeOwned::Borrowed(msg)).unwrap(); + let msg = crate::IrcMessage::parse(MaybeOwned::Borrowed(msg)).unwrap(); let pm = crate::messages::Privmsg::from_irc(msg).unwrap(); let tags = pm.tags();