Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow slice! macro to index tuples #2598

Merged
merged 3 commits into from
May 29, 2024

Conversation

SleeplessOne1917
Copy link
Contributor

Currently, the slice! macro breaks when trying to index a tuple. Example:

use leptos::*;

#[derive(Clone, PartialEq, Eq)]
struct PostView {
    pub post: Post,
    pub creator: String
}

#[derive(Clone, PartialEq, Eq)]
struct Post {
    pub body: String,
    pub id: PostId
}

#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
struct PostId(pub i32);

let post = RwSignal::new(
    PostView {
        creator: "Bob".to_owned(),
        post: Post {
            body: "Hello World!!!".to_owned(),
            id: PostId(42)
        }
    }
);

let id = slice!(post.post.id.0); // Does not compile!

This change allows both identifiers and tuple indices to be used.

@gbj
Copy link
Collaborator

gbj commented May 27, 2024

Thanks! The leptos_macro/tests/ui tests that you changed are unrelated to the changes in this PR, I think, and your changes appear to cause the tests in CI to fail. Could you revert those changes?

(There may be a version mismatch between the compiler you're running them against locally and the compiler version running in CI, which would account for the different error messages maybe)

@SleeplessOne1917
Copy link
Contributor Author

@gbj I fixed the issue you pointed out. No clue why the semver step and the hacker new js fetch step are both failing.

@gbj
Copy link
Collaborator

gbj commented May 29, 2024

It's okay they are failing on main and I just haven't had time recently to look into it. Thanks very much, this looks good.

@gbj gbj merged commit 21a6551 into leptos-rs:main May 29, 2024
56 of 59 checks passed
@SleeplessOne1917 SleeplessOne1917 deleted the slice-tuple-fix branch May 29, 2024 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants