Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

Add a helper to flatten Result<Result<T>> with tokio_util #210

Merged
merged 1 commit into from
Jan 19, 2022

Conversation

cgwalters
Copy link
Member

I think this is nicer than having ?? which still looks odd to me,
and we can also drop a map(anyhow::Error::msg) in once place too.

Prep for further work.

Comment on lines 60 to 61
Ok(Ok(v)) => Ok(v),
Ok(Err(e)) => Err(e),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't this be written:

Suggested change
Ok(Ok(v)) => Ok(v),
Ok(Err(e)) => Err(e),
Ok(x) => x,

?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah nice! I started to reply "No because..." then I realized if you just look at it, it's clearly true.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my defense this code was inspired by rust-lang/rust#70142 (comment) but they're trying to support a "flatten with" which we're hardcoding to be anyhow! effectively. This code is also not as general because it requires the inner to be an anyhow::Result today.

I think this is nicer than having `??` which still looks odd to me,
and we can also drop a `map(anyhow::Error::msg)` in once place too.

Prep for further work.
@cgwalters cgwalters merged commit 67ffb88 into ostreedev:main Jan 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants