https://github.com/usagi/drop_ok
`.drop_ok` syntax sugar for `Result`. It's instead of `.map(|_|())`.
https://github.com/usagi/drop_ok
Last synced: 3 months ago
JSON representation
`.drop_ok` syntax sugar for `Result`. It's instead of `.map(|_|())`.
- Host: GitHub
- URL: https://github.com/usagi/drop_ok
- Owner: usagi
- License: mit
- Created: 2020-08-10T07:27:53.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-08-10T08:04:27.000Z (almost 6 years ago)
- Last Synced: 2025-03-23T21:11:28.229Z (about 1 year ago)
- Language: Rust
- Size: 8.79 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# drop_ok
- This crate defines `DropOk` trait and `impl` for `Result`.
- `DropOk` trait has `.drop_ok(self) -> Result<(), E>` function.
- This is a syntax sugar for `.map(|_|())`.
## Useful scene
```rust
fn some_function() -> Result<(), MyError>
{
match switcher
{
pattern_a => some_task1().drop_ok()?
pattern_b => some_task2().drop_ok()?
pattern_c => some_task3()?
pattern_d => some_task4()
_ => ()
}
}
fn some_task1() -> Result { /* abbr */ }
fn some_task2<'a>() -> Result<&'a str, MyError> { /* abbr */ }
fn some_task3() -> Result<() , MyError> { /* abbr */ }
fn some_task4() { /* abbr */ }
```
- See also:
## Note
> "I don't need it, because ..."
- Yes, your are right to your world.
- But, I tired to type/see `.map(|_|())`. So I'm happy with`.drop_ok()`.
## LICENSE
- [MIT](LICENSE.md)
## Author
- USAGI.NETWORK / Usagi Ito