#[export] infer VariantType by mio991 · Pull Request #147 · godot-rust/gdext (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation5 Commits1 Checks0 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

mio991

I removed the explicit VariantType declaration and replaced it with the ability to infer the same.

Also added an implementation for VariantMetadata for Option not sure if this is good but it was necessary.

Bromeon

Member

@Bromeon Bromeon left a comment • Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great simplification, thank you!

Sorry for the merge conflicts, I changed the proc-macro insides yesterday. Could you rebase onto master and squash into a single commit? Let me know if you need any help 🙂

Comment on lines +42 to +46

impl<T: VariantMetadata> VariantMetadata for Option {
fn variant_type() -> VariantType {
T::variant_type()
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to statically (at compile time) determine a variant type for a given Rust type.

Option::None however would typically correspond to NIL -- may that cause problems?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can see it, every time you recive a Variant it could be NIL even if you have declared another type.

For example if you reset a Property in the Inspector per default it gets set to NIL.

@mio991

@Bromeon

@bors

Labels

c: register

Register classes, functions and other symbols to GDScript

quality-of-life

No new functionality, but improves ergonomics/internals

2 participants

@mio991 @Bromeon