Skip to content

Commit

Permalink
chore: make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
ctron committed Dec 19, 2023
1 parent 0b80cfe commit c9f353b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
//! # use yew::prelude::*;
//! # use yew_nested_router::prelude::*;
//! # #[derive(Clone, Debug, PartialEq, Eq, Target)]
//! # pub enum AppRoute { Index };
//! # pub enum AppRoute { Index }
//! # #[function_component(MyContent)] fn my_content() -> Html { html!() }
//! #[function_component(MyApp)]
//! pub fn my_app() -> Html {
Expand Down
9 changes: 2 additions & 7 deletions src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ impl<T: Target> Router<T> {
.split('/')
.skip(1)
// urldecode in the process
.map(|segment| urlencoding::decode(segment))
.map(urlencoding::decode)
.collect();

// get a path, or return none if we had an urldecode error
Expand All @@ -286,12 +286,7 @@ impl<T: Target> Router<T> {
};

// parse the path into a target
// log::debug!("Path: {path:?}");
let target = T::parse_path(&path);
// log::debug!("New target: {target:?}");

// done
target
T::parse_path(&path)
}

fn sync_context(&mut self, ctx: &Context<Self>) {
Expand Down
25 changes: 13 additions & 12 deletions yew-nested-router-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ fn nested_field<P>(
return (values, Some(field));
}
} else {
#[allow(clippy::collapsible_else_if)]
if opts.nested.is_present() {
panic!(
"Only the last field can be a nested target: {}",
Expand Down Expand Up @@ -148,14 +149,14 @@ fn render_path(data: &DataEnum) -> impl Iterator<Item = TokenStream> + '_ {
}

/// generate iterators for capturing and rendering values
fn capture_values<'f, P, F>(
fn capture_values<P, F>(
expect_target: bool,
fields: &'f Punctuated<Field, P>,
fields: &Punctuated<Field, P>,
skip_nested: TokenStream,
push: F,
) -> (
impl Iterator<Item = TokenStream> + 'f,
impl Iterator<Item = TokenStream> + 'f,
impl Iterator<Item = TokenStream> + '_,
impl Iterator<Item = TokenStream> + '_,
)
where
F: Fn(&Ident) -> TokenStream + 'static,
Expand Down Expand Up @@ -188,7 +189,7 @@ fn render_self(data: &DataEnum) -> impl Iterator<Item = TokenStream> + '_ {
let name = &v.ident;

let opts = Opts::from_variant(v).expect("Unable to parse options");
let disc = to_discriminator(&v, &opts);
let disc = to_discriminator(v, &opts);

match &v.fields {
// plain route
Expand Down Expand Up @@ -235,7 +236,7 @@ fn parse_path(data: &DataEnum) -> impl Iterator<Item = TokenStream> + '_ {
let name = &v.ident;

let opts = Opts::from_variant(v).expect("Unable to parse options");
let value = to_discriminator(&v, &opts);
let value = to_discriminator(v, &opts);

match &v.fields {
Fields::Unit => {
Expand All @@ -244,20 +245,20 @@ fn parse_path(data: &DataEnum) -> impl Iterator<Item = TokenStream> + '_ {
}
}
Fields::Unnamed(fields) => parse_rules(
&v,
v,
true,
&fields.unnamed,
|_, cap| from_str(&cap),
|_, cap| from_str(cap),
|_, target| quote!(#target),
|name, values, target| quote!(Some(Self::#name(#(#values, )* #target))),
),
Fields::Named(fields) => parse_rules(
&v,
v,
false,
&fields.named,
|name, cap| {
let name = name.expect("Must have a name");
let from = from_str(&cap);
let from = from_str(cap);
quote!(#name: #from)
},
|name, target| {
Expand Down Expand Up @@ -288,7 +289,7 @@ where
let (values, nested) = nested_field(expect_target, fields);

let opts = Opts::from_variant(v).expect("Unable to parse options");
let disc = to_discriminator(&v, &opts);
let disc = to_discriminator(v, &opts);

let (captures, values): (Vec<_>, Vec<_>) = values
.iter()
Expand All @@ -308,7 +309,7 @@ where
Some(nested) => {
let t = &nested.ty;

let field_opts = FieldOpts::from_field(&nested).expect("Unable to parse field options");
let field_opts = FieldOpts::from_field(nested).expect("Unable to parse field options");

let default = match &field_opts.default {
Some(Override::Inherit) => {
Expand Down

0 comments on commit c9f353b

Please sign in to comment.