-
Notifications
You must be signed in to change notification settings - Fork 335
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
Modify examples to not call unwrap
#312
Comments
unwrap
.unwrap
This looks like a fun way to read example code, and help with cleanup. I can work on this if nobody else is. |
Since the code examples are by default wrapped in a The way around it is to add a fn foo() -> Result<> { around the example, but this means making the examples a bit bigger than they should be. Confirming here what is the approach you want to take. Going to send a WIP patch to clarify what I mean. Let me know what you think. |
I am looking at this again. Will report soon. Sorry for the delay. |
Replace unwrap() in doctests with `?` Fixes #312. - All results yielding `ParseError` in the doctests should now be handled with the ? operator. - Some other specific results are ~unwrapped with `expect()`~ mapped to a placeholder string message, such as in URLs that are not _cannot-be-a-base_. Users are then expected to adjust this mapping depending on their use case. Once #299 is resolved, we'll be able to propagate these normally. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-url/323) <!-- Reviewable:end -->
Nice! Thanks @Enet4 😄 |
Several examples in
url
callunwrap
. It's preferable to use?
to avoid teaching bad practices to new Rust coders. Modify the examples to have some hidden scaffolding to set up theResult
type and use?
instead.The text was updated successfully, but these errors were encountered: