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

Use IsA for property setters for non-final objects #838

Merged
merged 2 commits into from Sep 10, 2019

Conversation

@EPashkin
Copy link
Member

EPashkin commented Sep 7, 2019

imports.add("glib::object::IsA");
imports.add("glib::value::SetValueOptional");
if !*nullable {
//TODO: support nonnulable setter if found any

This comment has been minimized.

Copy link
@EPashkin

EPashkin Sep 7, 2019

Author Member

No nonnulable setters in gtk-rs

This comment has been minimized.

Copy link
@sdroege

sdroege Sep 7, 2019

Member

What does this mean? :)

This comment has been minimized.

Copy link
@EPashkin

EPashkin Sep 7, 2019

Author Member

I thought that maybe exists some property that can't be NULL,
then generator support this case too (with param: &T instead of param: Option<&T>).
But check shows that no that properties in gtk-rs crates, so I just add warning and ToDo.

This comment has been minimized.

Copy link
@sdroege

sdroege Sep 7, 2019

Member

Sounds fine to me

'\"' | '\\' => es.push('\\'),
_ => (),
}
es.push(c)

This comment has been minimized.

Copy link
@EPashkin

EPashkin Sep 7, 2019

Author Member

nightly clippy begin to nags about this and other .count()

This comment has been minimized.

Copy link
@sdroege

sdroege Sep 7, 2019

Member

What exactly does it complain about, can you paste?

This comment has been minimized.

Copy link
@EPashkin

EPashkin Sep 7, 2019

Author Member
warning: this call to `map()` won't have an effect on the call to `count()`
   --> src\codegen\general.rs:517:13
    |
517 |       let _ = s
    |  _____________^
518 | |         .chars()
519 | |         .map(|c| match c {
520 | |             '\"' | '\\' => {
...   |
525 | |         })
526 | |         .count();
    | |________________^
    |
    = note: `#[warn(clippy::suspicious_map)]` on by default
    = help: make sure you did not confuse `map` with `filter`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_map

This comment has been minimized.

Copy link
@sdroege

sdroege Sep 7, 2019

Member

Maybe you want for_each() here instead?

This comment has been minimized.

Copy link
@EPashkin

EPashkin Sep 7, 2019

Author Member

IMHO just for is better, no closure created etc.

This comment has been minimized.

Copy link
@sdroege

sdroege Sep 7, 2019

Member

For this kind of code, I agree, yes.

The closure is optimized away btw, but with a for loop it's simply more readable IMHO :)

.count();
map
.map(|k| (*k, format!("{}_", k)))
.collect()

This comment has been minimized.

Copy link
@EPashkin

EPashkin Sep 7, 2019

Author Member

Seems this case can be just collected without temporary HashMap

@EPashkin EPashkin force-pushed the EPashkin:set_property_IsA branch from 7594842 to 07f0765 Sep 8, 2019
@EPashkin EPashkin merged commit a615468 into gtk-rs:master Sep 10, 2019
2 checks passed
2 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@EPashkin EPashkin deleted the EPashkin:set_property_IsA branch Sep 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.