https://github.com/jimlynchcodes/unwrap-to-question-mark-challenge
https://github.com/jimlynchcodes/unwrap-to-question-mark-challenge
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/jimlynchcodes/unwrap-to-question-mark-challenge
- Owner: JimLynchCodes
- License: mit
- Created: 2023-03-28T16:14:21.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-29T04:14:57.000Z (about 3 years ago)
- Last Synced: 2025-02-04T11:55:08.786Z (over 1 year ago)
- Language: Rust
- Size: 9.77 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# unwrap-to-question-mark-challenge
## The Challenge
The challenge in this project is to refactor this Rust code that uses "unwrap" to instead use the question mark operator. Feel free to do any additional refactorings as well!
## Why?
The `unwrap` makes any error immediately crash your program and unwind. While this can be nice for moving quickly during development, panicking will crash every thread and makes your function signatures less descriptive. For this reason, many Rustaceans recommend refactoring `unwrap` to `?` before considering the code "production ready".
Changing from unwrap to ? can be tricky though, especially in situations (like this one) where a function could throw different kinds of errors. The hypothesis is that by solving this relatively simple unwrap-to-? you learn how to go from unwrap to ? in general!
## How To Submit A Solution
Open a PR with your refactorings to submit your solution!