From b25fada776c61013217540c0a3cd6f4294563c81 Mon Sep 17 00:00:00 2001 From: Stephen Andary Date: Wed, 25 Oct 2023 16:36:38 -0400 Subject: [PATCH] Add Newtype so that Rust-url can be IntoRoutable (#1579) * add newtype so that rust-url can IntoRoutable * add doc line * implement From directly --------- Co-authored-by: Evan Almloff --- packages/router/src/components/link.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/router/src/components/link.rs b/packages/router/src/components/link.rs index 787f9cdc9..639d99ae7 100644 --- a/packages/router/src/components/link.rs +++ b/packages/router/src/components/link.rs @@ -11,6 +11,8 @@ use crate::navigation::NavigationTarget; use crate::prelude::Routable; use crate::utils::use_router_internal::use_router_internal; +use url::Url; + /// Something that can be converted into a [`NavigationTarget`]. #[derive(Clone)] pub enum IntoRoutable { @@ -53,6 +55,18 @@ impl From<&str> for IntoRoutable { } } +impl From for IntoRoutable { + fn from(url: Url) -> Self { + IntoRoutable::FromStr(url.to_string()) + } +} + +impl From<&Url> for IntoRoutable { + fn from(url: &Url) -> Self { + IntoRoutable::FromStr(url.to_string()) + } +} + /// The properties for a [`Link`]. #[derive(Props)] pub struct LinkProps<'a> {