Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ all-features = true
default = []
testing = [
"async",
"async-mutex",
"async-lock",
]

async = [
Expand Down Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion src/irc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand Down
4 changes: 2 additions & 2 deletions src/irc/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/irc/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand All @@ -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))
}

Expand Down
28 changes: 14 additions & 14 deletions src/irc/tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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");
Expand All @@ -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());
Expand All @@ -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());
Expand All @@ -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);
Expand Down Expand Up @@ -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"));
Expand All @@ -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");
Expand All @@ -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();
Expand Down Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/maybe_owned/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl<'a> PartialEq<&str> for MaybeOwned<'a> {
impl<'a> AsRef<str> for MaybeOwned<'a> {
fn as_ref(&self) -> &str {
match self {
MaybeOwned::Owned(s) => &*s,
MaybeOwned::Owned(s) => s,
MaybeOwned::Borrowed(s) => s,
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/messages/cap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/messages/global_user_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"]);
}
}
Expand All @@ -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"]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/messages/user_notice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
}
2 changes: 1 addition & 1 deletion src/runner/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
}
2 changes: 1 addition & 1 deletion src/test/conn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/test/tags_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
Expand Down Expand Up @@ -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= :[email protected] 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();

Expand Down