fix clippy

This commit is contained in:
Evan Almloff 2023-07-26 11:29:34 -07:00
parent cc94711d62
commit d2ec27e761
4 changed files with 7 additions and 10 deletions

View file

@ -49,11 +49,7 @@ where
} }
} }
fn default_external_navigation_handler<R>() -> fn(Scope) -> Element fn default_external_navigation_handler() -> fn(Scope) -> Element {
where
R: dioxus_router::prelude::Routable,
<R as std::str::FromStr>::Err: std::fmt::Display,
{
dioxus_router::prelude::FailureExternalNavigation dioxus_router::prelude::FailureExternalNavigation
} }
@ -65,7 +61,7 @@ where
<R as std::str::FromStr>::Err: std::fmt::Display, <R as std::str::FromStr>::Err: std::fmt::Display,
{ {
#[serde(skip)] #[serde(skip)]
#[serde(default = "default_external_navigation_handler::<R>")] #[serde(default = "default_external_navigation_handler")]
failure_external_navigation: fn(Scope) -> Element, failure_external_navigation: fn(Scope) -> Element,
scroll_restoration: bool, scroll_restoration: bool,
#[serde(skip)] #[serde(skip)]

View file

@ -198,7 +198,7 @@ pub fn Link<'a>(cx: Scope<'a, LinkProps<'a>>) -> Element {
IntoRoutable::Route(route) => router.any_route_to_string(&**route), IntoRoutable::Route(route) => router.any_route_to_string(&**route),
}; };
let parsed_route: NavigationTarget<Box<dyn Any>> = match router.route_from_str(&href) { let parsed_route: NavigationTarget<Box<dyn Any>> = match router.route_from_str(&href) {
Ok(route) => NavigationTarget::Internal(route.into()), Ok(route) => NavigationTarget::Internal(route),
Err(err) => NavigationTarget::External(err), Err(err) => NavigationTarget::External(err),
}; };
let ac = active_class let ac = active_class

View file

@ -19,6 +19,8 @@ pub struct ExternalNavigationFailure(String);
/// A function the router will call after every routing update. /// A function the router will call after every routing update.
pub(crate) type RoutingCallback<R> = Arc<dyn Fn(LinkContext<R>) -> Option<NavigationTarget<R>>>; pub(crate) type RoutingCallback<R> = Arc<dyn Fn(LinkContext<R>) -> Option<NavigationTarget<R>>>;
pub(crate) type AnyRoutingCallback =
Arc<dyn Fn(RouterContext) -> Option<NavigationTarget<Box<dyn Any>>>>;
struct MutableRouterState { struct MutableRouterState {
/// The current prefix. /// The current prefix.
@ -36,7 +38,7 @@ pub struct RouterContext {
subscribers: Arc<RwLock<HashSet<ScopeId>>>, subscribers: Arc<RwLock<HashSet<ScopeId>>>,
subscriber_update: Arc<dyn Fn(ScopeId)>, subscriber_update: Arc<dyn Fn(ScopeId)>,
routing_callback: Option<Arc<dyn Fn(RouterContext) -> Option<NavigationTarget<Box<dyn Any>>>>>, routing_callback: Option<AnyRoutingCallback>,
failure_external_navigation: fn(Scope) -> Element, failure_external_navigation: fn(Scope) -> Element,
@ -250,7 +252,7 @@ impl RouterContext {
IntoRoutable::Route(route) => self.any_route_to_string(&**route), IntoRoutable::Route(route) => self.any_route_to_string(&**route),
}; };
let parsed_route: NavigationTarget<Box<dyn Any>> = match self.route_from_str(&href) { let parsed_route: NavigationTarget<Box<dyn Any>> = match self.route_from_str(&href) {
Ok(route) => NavigationTarget::Internal(route.into()), Ok(route) => NavigationTarget::Internal(route),
Err(err) => NavigationTarget::External(err), Err(err) => NavigationTarget::External(err),
}; };
parsed_route parsed_route

View file

@ -279,7 +279,6 @@ pub trait HistoryProvider<R: Routable> {
} }
pub(crate) trait AnyHistoryProvider { pub(crate) trait AnyHistoryProvider {
#[must_use]
fn parse_route(&self, route: &str) -> Result<Box<dyn Any>, String>; fn parse_route(&self, route: &str) -> Result<Box<dyn Any>, String>;
#[must_use] #[must_use]