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

It is tricky to figure out how to properly use WithBaseField generically #715

Closed
lilizoey opened this issue May 19, 2024 · 0 comments · Fixed by #716
Closed

It is tricky to figure out how to properly use WithBaseField generically #715

lilizoey opened this issue May 19, 2024 · 0 comments · Fixed by #716
Labels
documentation Improvements or additions to documentation

Comments

@lilizoey
Copy link
Member

lilizoey commented May 19, 2024

See this discord thread.

But basically there isn't any explicit documentation stating that in order to call self.base/base_mut(), the compiler must know the type of Self::Base. It could be useful to add an example somewhere of how to properly declare the bounds in the generic case.

The way to declare the bound in case you want the base to be Node3D is:

fn some_fn<T>(value: &T)
where
    T: WithBaseField + GodotClass<Base = Node3D>,
{
    let base = gd.base();
}
@lilizoey lilizoey added the documentation Improvements or additions to documentation label May 19, 2024
lokimckay added a commit to lokimckay/gdext that referenced this issue May 19, 2024
lokimckay added a commit to lokimckay/gdext that referenced this issue May 22, 2024
github-merge-queue bot pushed a commit that referenced this issue May 22, 2024
Add WithBaseField example to traits.rs (#715)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant