From c663a119da1664c064e48a352f271f593c887f4b Mon Sep 17 00:00:00 2001 From: aryonoco <25701165+aryonoco@users.noreply.github.com> Date: Thu, 23 Apr 2026 12:56:16 +1000 Subject: [PATCH] use case on oResultPrivate in map*Err for strictCaseObjects (#2) Replace the remaining `if self.oResultPrivate:` sites in mapConvertErr and mapCastErr with `case`, matching the style used in withAssertOk and every other map/flatMap/iterator in the file. Unblocks {.experimental: "strictCaseObjects".} consumers; no behavioural change for existing callers. --- results.nim | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/results.nim b/results.nim index 1cb516f..b769b09 100644 --- a/results.nim +++ b/results.nim @@ -705,12 +705,13 @@ func mapConvertErr*[T, E0](self: Result[T, E0], E1: type): Result[T, E1] {.inlin when E0 is E1: result = self else: - if self.oResultPrivate: + case self.oResultPrivate + of true: when T is void: result.ok() else: result.ok(self.vResultPrivate) - else: + of false: when E1 is void: result.err() else: @@ -719,12 +720,13 @@ func mapConvertErr*[T, E0](self: Result[T, E0], E1: type): Result[T, E1] {.inlin func mapCastErr*[T, E0](self: Result[T, E0], E1: type): Result[T, E1] {.inline.} = ## Convert result value to A using a cast ## Would be nice with nicer syntax... - if self.oResultPrivate: + case self.oResultPrivate + of true: when T is void: result.ok() else: result.ok(self.vResultPrivate) - else: + of false: result.err(cast[E1](self.eResultPrivate)) template `and`*[T0, E, T1](self: Result[T0, E], other: Result[T1, E]): Result[T1, E] =