mirror of
https://github.com/leptos-rs/leptos
synced 2024-11-10 06:44:17 +00:00
feat: allow slice! macro to index tuples (#2598)
* Allow slice! macro to index tuples * Undo changes to component tests --------- Co-authored-by: Greg Johnston <greg.johnston@gmail.com>
This commit is contained in:
parent
2f4fd87c05
commit
21a6551ce6
3 changed files with 9 additions and 6 deletions
|
@ -11,7 +11,7 @@ use syn::{
|
|||
|
||||
struct SliceMacroInput {
|
||||
root: syn::Ident,
|
||||
path: Punctuated<syn::Ident, Token![.]>,
|
||||
path: Punctuated<syn::Member, Token![.]>,
|
||||
}
|
||||
|
||||
impl Parse for SliceMacroInput {
|
||||
|
@ -19,7 +19,7 @@ impl Parse for SliceMacroInput {
|
|||
let root: syn::Ident = input.parse()?;
|
||||
input.parse::<Token![.]>()?;
|
||||
// do not accept trailing punctuation
|
||||
let path: Punctuated<syn::Ident, Token![.]> =
|
||||
let path: Punctuated<syn::Member, Token![.]> =
|
||||
Punctuated::parse_separated_nonempty(input)?;
|
||||
|
||||
if path.is_empty() {
|
||||
|
|
|
@ -10,9 +10,12 @@ pub struct OuterState {
|
|||
#[derive(Clone, PartialEq, Default)]
|
||||
pub struct InnerState {
|
||||
inner_count: i32,
|
||||
inner_name: String,
|
||||
inner_tuple: InnerTuple,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Default)]
|
||||
pub struct InnerTuple(String);
|
||||
|
||||
#[test]
|
||||
fn green() {
|
||||
let _ = create_runtime();
|
||||
|
@ -22,7 +25,7 @@ fn green() {
|
|||
let (_, _) = slice!(outer_signal.count);
|
||||
|
||||
let (_, _) = slice!(outer_signal.inner.inner_count);
|
||||
let (_, _) = slice!(outer_signal.inner.inner_name);
|
||||
let (_, _) = slice!(outer_signal.inner.inner_tuple.0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -14,7 +14,7 @@ error: expected `.`
|
|||
|
|
||||
= note: this error originates in the macro `slice` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: unexpected end of input, expected identifier
|
||||
error: unexpected end of input, expected identifier or integer
|
||||
--> tests/slice/red.rs:25:18
|
||||
|
|
||||
25 | let (_, _) = slice!(outer_signal.);
|
||||
|
@ -22,7 +22,7 @@ error: unexpected end of input, expected identifier
|
|||
|
|
||||
= note: this error originates in the macro `slice` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: unexpected end of input, expected identifier
|
||||
error: unexpected end of input, expected identifier or integer
|
||||
--> tests/slice/red.rs:27:18
|
||||
|
|
||||
27 | let (_, _) = slice!(outer_signal.inner.);
|
||||
|
|
Loading…
Reference in a new issue