Unwrap twice #41
Answered
by
carllerche
van-sprundel
asked this question in
Q&A
-
Hey, love the concept! Had a question about the following snippet: while let Some(todo) = todos.next().await {
let todo = todo.unwrap();
...
} I was curious why the design makes it necessary to unwrap twice. Can an item exist but be invalid? |
Beta Was this translation helpful? Give feedback.
Answered by
carllerche
Oct 31, 2024
Replies: 1 comment
-
There is only one unwrap there? I think it is because |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
van-sprundel
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There is only one unwrap there? I think it is because
next()
returnsOption<Result<_>>
. TheOption
returningNone
indicates the stream is empty.Result
tracks if there is an error or not.