Skip to content

Commit

Permalink
Fix clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
bschwind committed Aug 28, 2021
1 parent 04cdb40 commit fffa2f8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
4 changes: 2 additions & 2 deletions mqtt-v5-broker/src/broker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ impl Broker {
// Unsubscribe the old session from all topics it subscribed to.
session.subscription_tokens.retain(|(session_topic, token)| {
if *session_topic == *topic {
subscriptions.remove(&session_topic, *token);
subscriptions.remove(session_topic, *token);
false
} else {
true
Expand Down Expand Up @@ -391,7 +391,7 @@ impl Broker {
// Unsubscribe the old session from all topics it subscribed to.
session.subscription_tokens.retain(|(session_topic, token)| {
if *session_topic == *filter {
subscriptions.remove(&session_topic, *token);
subscriptions.remove(session_topic, *token);
false
} else {
true
Expand Down
24 changes: 8 additions & 16 deletions mqtt-v5-broker/src/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,35 +68,27 @@ impl<T: std::fmt::Debug> SubscriptionTreeNode<T> {
for level in topic_filter.levels() {
match level {
TopicLevel::SingleLevelWildcard => {
if current_tree.single_level_wildcards.is_some() {
current_tree = current_tree.single_level_wildcards.as_mut().unwrap();
} else {
if current_tree.single_level_wildcards.is_none() {
current_tree.single_level_wildcards =
Some(Box::new(SubscriptionTreeNode::new()));
current_tree = current_tree.single_level_wildcards.as_mut().unwrap();
}

current_tree = current_tree.single_level_wildcards.as_mut().unwrap();
},
TopicLevel::MultiLevelWildcard => {
multi_level = true;
break;
},
TopicLevel::Concrete(concrete_topic_level) => {
if current_tree.concrete_topic_levels.contains_key(concrete_topic_level) {
current_tree = current_tree
.concrete_topic_levels
.get_mut(concrete_topic_level)
.unwrap();
} else {
if !current_tree.concrete_topic_levels.contains_key(concrete_topic_level) {
current_tree
.concrete_topic_levels
.insert(concrete_topic_level.to_string(), SubscriptionTreeNode::new());

// TODO - Do this without another hash lookup
current_tree = current_tree
.concrete_topic_levels
.get_mut(concrete_topic_level)
.unwrap();
}

// TODO - Do this without another hash lookup
current_tree =
current_tree.concrete_topic_levels.get_mut(concrete_topic_level).unwrap();
},
}
}
Expand Down
4 changes: 2 additions & 2 deletions mqtt-v5/src/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,11 @@ fn encode_connect(packet: &ConnectPacket, bytes: &mut BytesMut, protocol_version
}

if let Some(user_name) = &packet.user_name {
encode_string(&user_name, bytes);
encode_string(user_name, bytes);
}

if let Some(password) = &packet.password {
encode_string(&password, bytes);
encode_string(password, bytes);
}
}

Expand Down

0 comments on commit fffa2f8

Please sign in to comment.