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

Idiomatic Rust #2

Open
matprec opened this issue Dec 14, 2016 · 1 comment
Open

Idiomatic Rust #2

matprec opened this issue Dec 14, 2016 · 1 comment

Comments

@matprec
Copy link

matprec commented Dec 14, 2016

Wouldn't it be more idiomatic to return Result instead of asserting hr == 0 all over the place?

Not exposing the abillity to fail and instead panicing makes the api unidiomatic in my opinion, since e.g. FontDescriptor can be manipulated by the user, which in turn can cause hr != 0.

@vvuk
Copy link
Owner

vvuk commented Jan 12, 2017

Probably -- the way the code evolved the hr == 0 assertions just lived on through. I'm open to making this API change later on. Note that things that can safely fail such as get_font_from_descriptor and stuff like FontCollection::get_font_family_by_name return Option. They only panic in case of bad/usage failure (I think). For example, calling FontCollection::get_font_family with an index that's out of range causes an assertion failure/panic.

kwonoj pushed a commit to kwonoj/dwrote-rs that referenced this issue Jul 8, 2018
Switch to serde_derive only
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

No branches or pull requests

2 participants