Skip to content

Commit

Permalink
Use result.lazy_or, as it is a bit cleaner if error is not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
JosephTLyons committed Oct 17, 2024
1 parent f5e949c commit ee1fe5e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/lenient_parse.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ pub fn to_float(text: String) -> Result(Float, ParseError) {
let text = text |> coerce_into_valid_number_string
use text <- result.try(text)
let res = text |> float.parse |> result.replace_error(GleamFloatParseError)
use _ <- result.try_recover(res)
use <- result.lazy_or(res)

text
|> int.parse
|> result.replace_error(GleamIntParseError)
Expand Down

0 comments on commit ee1fe5e

Please sign in to comment.