Skip to content

Commit

Permalink
Fixing heapless
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-summers committed Jun 13, 2024
1 parent 91e04c0 commit 5e28b73
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
//! ```
//!
use core::fmt::Write as CoreWrite;
use core::str::FromStr;
use embedded_io::Write;

pub use minimq;
Expand Down Expand Up @@ -398,7 +399,8 @@ where
fn subscribe(&mut self) -> Result<(), ()> {
// Note(unwrap): We ensure that this storage is always sufficiently large to store
// the wildcard post-fix for MQTT.
let mut prefix: String<{ MAX_TOPIC_LENGTH + 2 }> = String::from(self.prefix.as_str());
let mut prefix: String<{ MAX_TOPIC_LENGTH + 2 }> =
String::from_str(self.prefix.as_str()).unwrap();
prefix.push_str("/#").unwrap();

let topic_prefix = minimq::types::TopicFilter::new(&prefix)
Expand Down Expand Up @@ -449,7 +451,8 @@ where
{
// Note(unwrap): The unwrap cannot fail because of restrictions on the max topic
// length.
let mut topic: String<{ 2 * MAX_TOPIC_LENGTH + 1 }> = String::from(prefix.as_str());
let mut topic: String<{ 2 * MAX_TOPIC_LENGTH + 1 }> =
String::from_str(prefix.as_str()).unwrap();
topic.push_str("/").unwrap();
topic.push_str(command_prefix).unwrap();

Expand Down

0 comments on commit 5e28b73

Please sign in to comment.