Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add rustfmt.toml && simplify PartialEq on str for Frame #107

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
Empty file added rustfmt.toml
Empty file.
12 changes: 6 additions & 6 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ impl Client {
/// The core `SUBSCRIBE` logic, used by misc subscribe fns
async fn subscribe_cmd(&mut self, channels: &[String]) -> crate::Result<()> {
// Convert the `Subscribe` command into a frame
let frame = Subscribe::new(&channels).into_frame();
let frame = Subscribe::new(channels).into_frame();

debug!(request = ?frame);

Expand All @@ -323,7 +323,7 @@ impl Client {
// num-subscribed is the number of channels that the client
// is currently subscribed to.
[subscribe, schannel, ..]
if *subscribe == "subscribe" && *schannel == channel => {}
if subscribe == "subscribe" && schannel == channel.as_str() => {}
_ => return Err(response.to_error()),
},
frame => return Err(frame.to_error()),
Expand Down Expand Up @@ -374,7 +374,7 @@ impl Subscriber {

match mframe {
Frame::Array(ref frame) => match frame.as_slice() {
[message, channel, content] if *message == "message" => Ok(Some(Message {
[message, channel, content] if message == "message" => Ok(Some(Message {
channel: channel.to_string(),
content: Bytes::from(content.to_string()),
})),
Expand Down Expand Up @@ -423,7 +423,7 @@ impl Subscriber {
/// Unsubscribe to a list of new channels
#[instrument(skip(self))]
pub async fn unsubscribe(&mut self, channels: &[String]) -> crate::Result<()> {
let frame = Unsubscribe::new(&channels).into_frame();
let frame = Unsubscribe::new(channels).into_frame();

debug!(request = ?frame);

Expand All @@ -445,7 +445,7 @@ impl Subscriber {

match response {
Frame::Array(ref frame) => match frame.as_slice() {
[unsubscribe, channel, ..] if *unsubscribe == "unsubscribe" => {
[unsubscribe, channel, ..] if unsubscribe == "unsubscribe" => {
let len = self.subscribed_channels.len();

if len == 0 {
Expand All @@ -454,7 +454,7 @@ impl Subscriber {
}

// unsubscribed channel should exist in the subscribed list at this point
self.subscribed_channels.retain(|c| *channel != &c[..]);
self.subscribed_channels.retain(|c| channel != &c[..]);

// Only a single channel should be removed from the
// list of subscribed channels.
Expand Down
4 changes: 2 additions & 2 deletions src/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ impl Frame {
}
}

impl PartialEq<&str> for Frame {
fn eq(&self, other: &&str) -> bool {
impl PartialEq<str> for Frame {
fn eq(&self, other: &str) -> bool {
match self {
Frame::Simple(s) => s.eq(other),
Frame::Bulk(s) => s.eq(other),
Expand Down