|
177 | 177 | ## echo "Never run" # the first statement returns a none option, which when
|
178 | 178 | ## # compared to 2 returns another none option. This none option is then
|
179 | 179 | ## # obviously not a some. Note that in this case it would be better to use
|
180 |
| -## # a `match`. |
| 180 | +## # a `require`. |
181 | 181 |
|
182 | 182 | import typetraits
|
183 | 183 | import macros
|
@@ -233,13 +233,13 @@ proc isNone*[T](self: Option[T]): bool {.inline.} =
|
233 | 233 | else:
|
234 | 234 | not self.has
|
235 | 235 |
|
236 |
| -proc unsafeGet*[T](self: Option[T]): T {.deprecated: "Use `match`, `.?`, or " & |
| 236 | +proc unsafeGet*[T](self: Option[T]): T {.deprecated: "Use `require`, `.?`, or " & |
237 | 237 | "special form `or` and `and` instead of manual checks".} =
|
238 | 238 | ## Returns the value of a ``some``. Behavior is undefined for ``none``.
|
239 | 239 | assert self.isSome
|
240 | 240 | self.val
|
241 | 241 |
|
242 |
| -proc get*[T](self: Option[T]): T {.deprecated: "Use `match`, `.?`, or " & |
| 242 | +proc get*[T](self: Option[T]): T {.deprecated: "Use `require`, `.?`, or " & |
243 | 243 | "special form `or` and `and` instead of manual checks".}=
|
244 | 244 | ## Returns contents of the Option. If it is none, then an exception is
|
245 | 245 | ## thrown.
|
@@ -609,7 +609,7 @@ macro wrapException*(statement: untyped): untyped =
|
609 | 609 | ## let optParseInt = wrapException: parseInt(x: string)
|
610 | 610 | ## # This will run the first parsing, then stop because it returns a some
|
611 | 611 | ## # option with the exception.
|
612 |
| - ## match optParseInt("bob") or optParseInt("20"): |
| 612 | + ## require optParseInt("bob") or optParseInt("20"): |
613 | 613 | ## just e: echo e.msg
|
614 | 614 | ## none: echo "Execution succeded"
|
615 | 615 | assert(statement.len == 1)
|
@@ -650,7 +650,7 @@ macro wrapErrorCode*(statement: untyped): untyped =
|
650 | 650 | ## let optParseInt = wrapErrorCode: parseInt(x: string)
|
651 | 651 | ## # This will run the first parsing, then stop because it returns a some
|
652 | 652 | ## # option with the "error code".
|
653 |
| - ## match optParseInt("10") or optParseInt("0"): |
| 653 | + ## require optParseInt("10") or optParseInt("0"): |
654 | 654 | ## just e: echo "Got error code: ", e
|
655 | 655 | ## none: echo "Execution succeded"
|
656 | 656 | assert(statement.len == 1)
|
|
0 commit comments