Skip to content

Commit

Permalink
Add BoundResult.exit()
Browse files Browse the repository at this point in the history
  • Loading branch information
ilotoki0804 committed Sep 14, 2024
1 parent e0f52e1 commit 834a7cf
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/fieldenum/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
from __future__ import annotations

import functools
from typing import TYPE_CHECKING, Any, Callable, final, overload
import sys
from typing import TYPE_CHECKING, Any, Callable, NoReturn, final, overload

from . import Unit, Variant, fieldenum, unreachable
from .exceptions import IncompatibleBoundError
Expand Down Expand Up @@ -244,6 +245,9 @@ def as_option(self) -> Option[R]:
case other:
unreachable(other)

def exit(self, error_code: str | int | None = 1) -> NoReturn:
sys.exit(error_code if self else 0)

def rebound[NewBound: BaseException](self, bound: type[NewBound], /) -> BoundResult[R, NewBound]:
match self:
case BoundResult.Success(value, _):
Expand Down

0 comments on commit 834a7cf

Please sign in to comment.