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

glib: Implement IntoOptionalGStr for plain string types #891

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sdroege
Copy link
Member

@sdroege sdroege commented Jan 13, 2023

This way strings can be passed to such functions without explicit Option wrapping, see #805.


CC @jf2048 @fengalin

Not sure if we want this change already for this release

This way strings can be passed to such functions without explicit
`Option` wrapping, see gtk-rs#805.
@jf2048
Copy link
Member

jf2048 commented Jan 18, 2023

TBH not a fan of this. I think Into<Option<String>> is getting too far away from idiomatic Rust

@sdroege
Copy link
Member Author

sdroege commented Jan 18, 2023

@jf2048 You probably want to comment in #805 then. This PR comes from the discussions there :)

@fengalin
Copy link
Contributor

My position has shifted two days after my initial try on #805. See this comment. Sorry if that lead to confusions, I made it clear in the initial comment now.

The short version of my most recent position is:

  • If the None case is the default, then the function with the same name as in the sys crate should NOT use any argument for the optional value. Another function with an explicit name would accept a non-Option argument to pass the value when needed.
  • If the Some case is the default, then the function with the same name as in the sys crate should accept a non-Option argument to pass the value. Another function with an explicit name could allow selecting the None case.
  • In both cases, another function such as unset_*, discard_* or reset_* would allow switching from Some value to None when necessary.

@GuillaumeGomez
Copy link
Member

Thanks for the clarification! More functions but less arguments. I like this approach a lot.

@sdroege sdroege modified the milestones: 0.17.0, 0.18.0 Jan 21, 2023
@bilelmoussaoui bilelmoussaoui modified the milestones: 0.18.0, 0.20 May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants