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

Can't use Self in generic when deriving Properties #3557

Open
Victor-N-Suadicani opened this issue Dec 11, 2023 · 0 comments · May be fixed by #3569
Open

Can't use Self in generic when deriving Properties #3557

Victor-N-Suadicani opened this issue Dec 11, 2023 · 0 comments · May be fixed by #3569
Labels

Comments

@Victor-N-Suadicani
Copy link

Problem

Example code should explain the problem:

use std::marker::PhantomData;

use yew::prelude::*;

#[derive(PartialEq, Eq)]
struct Generic<T>(PhantomData<T>);

// This works fine.
#[derive(Properties, PartialEq, Eq)]
struct Properties1 {
    gen: Generic<Properties1>,
}

// This doesn't work, even though it's equivalent.
#[derive(Properties, PartialEq, Eq)]
struct Properties2 {
    gen: Generic<Self>,
}

Steps To Reproduce
Steps to reproduce the behavior:

  1. Compile above code without Properties2.
  2. Observe that it compiles.
  3. Run above code with Properties2.
  4. Observe that it does not compile.

Expected behavior
The code with Properties2 should compile as it is equivalent to the first one. Probably the problem lies in the Self keyword being misunderstood as the fields are put into a different struct.

Environment:

  • Yew version: v0.21
  • Rust version: 1.74.1
@schvv31n schvv31n linked a pull request Dec 22, 2023 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant