got rid of 'accept' dir in the tests
This commit is contained in:
parent
d0772feb08
commit
a274f3bf5b
264 changed files with 5 additions and 7 deletions
23
tests/compile/tgenericvariant.nim
Executable file
23
tests/compile/tgenericvariant.nim
Executable file
|
|
@ -0,0 +1,23 @@
|
|||
type
|
||||
TMaybe[T] = object
|
||||
case empty: Bool
|
||||
of False: value: T
|
||||
else: nil
|
||||
|
||||
proc Just*[T](val: T): TMaybe[T] =
|
||||
result.empty = False
|
||||
result.value = val
|
||||
|
||||
proc Nothing[T](): TMaybe[T] =
|
||||
result.empty = True
|
||||
|
||||
proc safeReadLine(): TMaybe[string] =
|
||||
var r = stdin.readLine()
|
||||
if r == "": return Nothing[string]()
|
||||
else: return Just(r)
|
||||
|
||||
when isMainModule:
|
||||
var Test = Just("Test")
|
||||
echo(Test.value)
|
||||
var mSomething = safeReadLine()
|
||||
echo(mSomething.value)
|
||||
Loading…
Add table
Add a link
Reference in a new issue