You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure why .into() is called on #value - was this a deliberate decision to automatically call .into()? This might be a good API choice, so that many different inputs can be used, without the directive author needing to make the parameter impl Into<MyParameter>. This should also be documented, something I can add to the book once this is clarified.
However, this is inconsistent as into is not called on the no-value alternative, (). There may be cases where there is a sensible default if the user doesn't provide any parameter, but right now the directive author can't add a impl From<()> for MyParameter to accept it.
❗ I'm not sure if this is a breaking change to add .into() though.
Another bit: the first branch should be (#value).into() so that into is called on the whole value passed in, not just added to the end. For example, this wouldn't work:
structParam;impl<T:Fn() -> i32>From<T>forParam{// ...}fndirective(el:HtmlElement<AnyElement>,p:Param){/* ... */}// this doesn't work: expands to `|| 10.into()`view!{<divuse:directive=||10 />}// currently have to do this to get `{|| 10}.into()`view!{<divuse:directive={||10} />}
I think fixing this won't be a breaking change.
I can make a PR to fix these issues, just wanted to check what the intended behaviour was and if this might be a breaking change.
Leptos Dependencies
leptos = { version = "0.6", features = ["csr"] }
To Reproduce
described above.
Expected behavior
also described above.
Screenshots
N/A
Additional context
N/A
The text was updated successfully, but these errors were encountered:
the first branch should be (#value).into() so that into is called on the whole value passed in
You are right, and this is a good catch. It might require some additional #[allow(unused_parens)] somewhere to suppress warnings in the cases where they aren't needed; not sure, worth checking if you're working on it.
I can make a PR to fix these issues, just wanted to check what the intended behaviour was and if this might be a breaking change.
Describe the bug
The implementation of directives on the macro seems to have somewhat inconsistent behaviour.
The current implementation is this:
I'm not sure why
.into()
is called on#value
- was this a deliberate decision to automatically call.into()
? This might be a good API choice, so that many different inputs can be used, without the directive author needing to make the parameterimpl Into<MyParameter>
. This should also be documented, something I can add to the book once this is clarified.However, this is inconsistent as
into
is not called on the no-value alternative,()
. There may be cases where there is a sensible default if the user doesn't provide any parameter, but right now the directive author can't add aimpl From<()> for MyParameter
to accept it.❗ I'm not sure if this is a breaking change to add
.into()
though.Another bit: the first branch should be
(#value).into()
so thatinto
is called on the whole value passed in, not just added to the end. For example, this wouldn't work:I think fixing this won't be a breaking change.
I can make a PR to fix these issues, just wanted to check what the intended behaviour was and if this might be a breaking change.
Leptos Dependencies
To Reproduce
described above.
Expected behavior
also described above.
Screenshots
N/A
Additional context
N/A
The text was updated successfully, but these errors were encountered: