Skip to content
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Compact message pattern matching
  • Loading branch information
dippi committed Jul 4, 2021
commit f2056c5d06a37638478e8752b265f08fe38b49bf
13 changes: 4 additions & 9 deletions src/client/pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,10 @@ impl PubsubConnectionInner {
messages.pop(),
messages.pop(),
) {
(Some(msg), Some(topic), Some(message_type), None) => {
match (msg, String::from_resp(topic), message_type) {
(msg, Ok(topic), resp::RespValue::BulkString(bytes)) => (bytes, topic, msg),
_ => return Err(error::unexpected("Incorrect format of a PUBSUB message")),
}
}
(Some(msg), Some(_), Some(topic), Some(message_type)) => {
match (msg, String::from_resp(topic), message_type) {
(msg, Ok(topic), resp::RespValue::BulkString(bytes)) => (bytes, topic, msg),
(Some(msg), Some(topic), Some(message_type), None)
| (Some(msg), Some(_), Some(topic), Some(message_type)) => {
match (String::from_resp(topic), message_type) {
(Ok(topic), resp::RespValue::BulkString(bytes)) => (bytes, topic, msg),
_ => return Err(error::unexpected("Incorrect format of a PUBSUB message")),
}
}
Expand Down