Confusing to use
&& result.then
#3157
Unanswered
Jedsek
asked this question in
Questions & support
Replies: 2 comments
-
oh, I think it's enough for me now:) fn try_from(header_line: String) -> Result(Header, String) {
let infos = header_line |> string.trim |> string.split(" ") |> iterator.from_list
use <- bool.guard(when: infos |> iterator.length < 6, return: Error("headerline is illegal"))
use str <- result.then(infos |> iterator.first |> result.replace_error("no first elem"))
use signature_with_hardblank <- result.then(str |> extract_signature_with_hardblank)
// ... |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hello! We don't do any implicit casts so you'll need to design and use your error type however is best for your code. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
consider this following code:
How to avoid this
result.replace_error("")
for type convertion? (Because I would not use this""
)Supposing there is a different error type...(create new one every time...)
Are there any function like
result.then
, butResult(a, b) -> Result(c, d)
rust version code with
? operator
forearly return
:Beta Was this translation helpful? Give feedback.
All reactions