Make new enum router less breaking

This commit is contained in:
Evan Almloff committed 2023-07-24 11:57:56 -07:00
1 parent b51ffa0590
commit 61dc549ba1
16 files changed
+74 -63

No files matched your search

+16 -5
View File
@@ -1,7 +1,6 @@
//! Types pertaining to navigation.
use std::{
convert::TryFrom,
fmt::{Debug, Display},
str::FromStr,
};
@@ -55,11 +54,23 @@ pub enum NavigationTarget<R: Routable> {
External(String),
}
impl<R: Routable> TryFrom<&str> for NavigationTarget<R> {
type Error = NavigationTargetParseError<R>;
impl<R: Routable> From<&str> for NavigationTarget<R> {
fn from(value: &str) -> Self {
value
.parse()
.unwrap_or_else(|_| Self::External(value.to_string()))
}
}
fn try_from(value: &str) -> Result<Self, Self::Error> {
value.parse()
impl<R: Routable> From<&String> for NavigationTarget<R> {
fn from(value: &String) -> Self {
value.as_str().into()
}
}
impl<R: Routable> From<String> for NavigationTarget<R> {
fn from(value: String) -> Self {
value.as_str().into()
}
}