apply clippy suggestions

This commit is contained in:
Adrian Wannenmacher committed 2022-12-13 16:19:40 +01:00
1 parent 83f6984b0a
commit 4677a00adc
13 files changed
+18 -22

No files matched your search

@@ -4,7 +4,7 @@ use dioxus_router_core::prelude::{named, FailureExternalNavigation as FENName, R
#[allow(non_snake_case)]
pub fn FailureExternalNavigation(cx: Scope) -> Element {
let state = use_route(&cx).expect(
let state = use_route(cx).expect(
"`FailureExternalNavigation` can only be mounted by the router itself, \
since it is not exposed",
);
@@ -56,7 +56,7 @@ pub fn GoBackButton<'a>(cx: Scope<'a, HistoryButtonProps<'a>>) -> Element {
let HistoryButtonProps { children } = cx.props;
// hook up to router
let router = match use_router_internal(&cx) {
let router = match use_router_internal(cx) {
Some(r) => r,
#[allow(unreachable_code)]
None => {
@@ -131,7 +131,7 @@ pub fn GoForwardButton<'a>(cx: Scope<'a, HistoryButtonProps<'a>>) -> Element {
let HistoryButtonProps { children } = cx.props;
// hook up to router
let router = match use_router_internal(&cx) {
let router = match use_router_internal(cx) {
Some(r) => r,
#[allow(unreachable_code)]
None => {
+1 -1
View File
@@ -114,7 +114,7 @@ pub fn Link<'a>(cx: Scope<'a, LinkProps<'a>>) -> Element {
} = cx.props;
// hook up to router
let router = match use_router_internal(&cx) {
let router = match use_router_internal(cx) {
Some(r) => r,
#[allow(unreachable_code)]
None => {
+1 -1
View File
@@ -69,7 +69,7 @@ pub fn Outlet(cx: Scope<OutletProps>) -> Element {
let OutletProps { depth, name } = cx.props;
// hook up to router
let router = match use_router_internal(&cx) {
let router = match use_router_internal(cx) {
Some(r) => r,
#[allow(unreachable_code)]
None => {
@@ -58,7 +58,6 @@ use crate::{RouterError, utils::use_router_internal::use_router_internal};
/// # let _ = vdom.rebuild();
/// # assert_eq!(dioxus_ssr::render(&vdom), "<h1>App</h1><p>Content</p>");
/// ```
#[must_use]
pub fn use_navigate(cx: &ScopeState) -> Result<Navigator<ScopeId>, RouterError> {
match use_router_internal(cx) {
Some(r) => Ok(r.sender.clone().into()),
+1 -4
View File
@@ -56,10 +56,7 @@ use crate::{utils::use_router_internal::use_router_internal, RouterError};
/// ```
///
/// [`use_router`]: crate::hooks::use_router
#[must_use]
pub fn use_route<'a>(
cx: &'a ScopeState,
) -> Result<RwLockReadGuard<'a, RouterState<Component>>, RouterError> {
pub fn use_route(cx: &ScopeState) -> Result<RwLockReadGuard<RouterState<Component>>, RouterError> {
match use_router_internal(cx) {
Some(r) => loop {
if let Some(s) = r.state.try_read() {
+1 -1
View File
@@ -192,7 +192,7 @@ impl Default for RouterConfiguration {
failure_external_navigation: comp(FailureExternalNavigation),
failure_named_navigation: comp(FailureNamedNavigation),
failure_redirection_limit: comp(FailureRedirectionLimit),
history: Box::new(MemoryHistory::default()),
history: Box::<MemoryHistory>::default(),
on_update: None,
synchronous: false,
}
@@ -15,7 +15,7 @@ use crate::contexts::router::RouterContext;
/// - Otherwise [`Some`].
///
/// [`use_router`]: crate::hooks::use_router
pub(crate) fn use_router_internal<'a>(cx: &'a ScopeState) -> &'a mut Option<RouterContext> {
pub(crate) fn use_router_internal(cx: &ScopeState) -> &mut Option<RouterContext> {
let id = cx.use_hook(|| Arc::new(cx.scope_id()));
cx.use_hook(|| {