aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gleam/dynamic.gleam8
1 files changed, 1 insertions, 7 deletions
diff --git a/src/gleam/dynamic.gleam b/src/gleam/dynamic.gleam
index 890b44d..bf6afd1 100644
--- a/src/gleam/dynamic.gleam
+++ b/src/gleam/dynamic.gleam
@@ -61,13 +61,7 @@ if erlang {
///
pub fn string(from: Dynamic) -> Result(String, DecodeError) {
bit_string(from)
- |> result.map_error(fn(error) {
- case error {
- DecodeError(_expected, found) ->
- // Convert error so it doesn't say expected 'BitString'
- DecodeError(expected: "String", found: found)
- }
- })
+ |> result.map_error(fn(error) { DecodeError(..error, expected: "String") })
|> result.then(fn(raw) {
case bit_string.to_string(raw) {
Ok(string) -> Ok(string)