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

Type parameters better have defaults in the presence of Option #143

Open
gkoz opened this issue Oct 13, 2015 · 4 comments
Open

Type parameters better have defaults in the presence of Option #143

gkoz opened this issue Oct 13, 2015 · 4 comments

Comments

@gkoz
Copy link
Member

gkoz commented Oct 13, 2015

This

pub fn set_label_widget<T: Upcast<Widget>>(&self, label_widget: Option<&T>)

requires jumping through hoops to pass None:

    x.set_label_widget(None::<Widget>);

There's not much we can do to help it at the moment, because default type parameters don't inform type inference yet. When that is fixed the following signature is going to be more ergonomic;

pub fn set_label_widget<T: Upcast<Widget> = Widget>(&self, label_widget: Option<&T>)
@gkoz gkoz added this to the object_reform milestone Jan 7, 2016
@homu homu closed this as completed in #186 Jan 9, 2016
homu added a commit that referenced this issue Jan 9, 2016
Provide type parameter defaults for optional parameters

Closes #143
@gkoz
Copy link
Member Author

gkoz commented Jan 13, 2016

Apparently, I've jumped the gun on this one. It looks like type parameter defaults on functions are going to be feature gated (rust-lang/rust#27336).

@gkoz gkoz removed this from the object_reform milestone Jan 13, 2016
@gkoz gkoz reopened this Jan 13, 2016
@leoyvens
Copy link

What about using trait objects? Isn't the widget is a gtk pointer anyways?

@sdroege
Copy link
Member

sdroege commented Mar 12, 2018

Trait objects don't work with the IsA trait currently https://github.com/gtk-rs/glib/issues/222

Are type parameter defaults stable now?

@sdroege
Copy link
Member

sdroege commented Mar 12, 2018

No not stable yet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants