Implement From trait for ChannelIdent for &str and String conversion
See the habitat and builder PRs for the improved ergonomics this allows.
@@ -90,10 +90,6 @@ impl ChannelIdent {
crate::env::var(key).map(ChannelIdent)
}
- pub fn from(s: &str) -> Self {
- ChannelIdent(s.to_string())
- }
-
pub fn as_str(&self) -> &str {
self.0.as_str()
}
@@ -121,6 +117,18 @@ impl ChannelIdent {
}
}
+impl From<&str> for ChannelIdent {
+ fn from(s: &str) -> Self {
+ ChannelIdent(s.to_string())
+ }
+}
+
+impl From<String> for ChannelIdent {
+ fn from(s: String) -> Self {
+ ChannelIdent(s)
+ }
+}
+
impl fmt::Display for ChannelIdent {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.0)
