Closed kozel-sd closed 4 months ago
The only thing that makes sense to return is Option<Config>
in case you just don't want anything you've asked for. If no suitable config was found it'll fail earlier, before even calling the picker.
So for me it sounds like your issue is theoretical and not practical.
I'd say that the current situation is ok though, because you're guaranteed to have a Config
that matches your criteria.
I've requested an impossible config with ConfigTemplateBuilder
in my app and got "argument does not name a valid config"
. If this is how it's meant to work if there is no suitable config (even if requested configs are theoretically possible, not anything like "71 alpha bits"), I get the idea. In this case, we can close this issue.
At some point, I forgot why ConfigTemplateBuilder
exists and thought about filtering configs in the picker...
When you ask for config there could be multiple that suits what you've asked for. When you don't specify what you want, the default config values are used, but they still could result in a lot of config matching the criteria.
When you ask something that doesn't exist at all, it'll error as it does for you now.
Choosing the option #4 and closing
Is there a significant reason why config picker must return
Config
with no room for a failure? If I understand Rust correctly (I'm not very experienced in it), if no suitable config has been found, the only option now is to panic and eventually terminate at the point wherebuild
is called. What if someone wants to handle that as a recoverable error?I see the following options:
Option<Config>
and return a specific error defined by glutin if the picker returnsNone
Result<Config, Whatever>
and propagate the error returned by ittry_build
Some context: I'm developing an app for myself, and everything works. But
unwrap
where a failure is theoretically possible still looks a bit dirty. I've created this issue right now because I think it's better to improve the interface while it's unstable. If I'm not the first one with a suggestion like this (it looks obvious, I suppose) - well, I tried searching.