-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Turns out having anything with any sort of lifetime in stream/sink chains will trigger nasty issues such as rust-lang/rust#79648 which is pretty difficult to figure out how to work around. Making `Topic` a newtype erases the lifetime from the type, making it significantly easier to work with in thsoe contexts.
- Loading branch information
Showing
4 changed files
with
25 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/// A message queue topic name to which messages can be published | ||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] | ||
pub struct Topic(pub &'static str); | ||
|
||
impl std::fmt::Display for Topic { | ||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
std::fmt::Display::fmt(self.0, f) | ||
} | ||
} | ||
|
||
impl From<&'static str> for Topic { | ||
fn from(s: &'static str) -> Topic { | ||
Topic(s) | ||
} | ||
} | ||
|
||
impl From<Topic> for &'static str { | ||
fn from(s: Topic) -> &'static str { | ||
s.0 | ||
} | ||
} |