mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
Added test for #1846.
This commit is contained in:
16
tests/closure/tissue1846.nim
Normal file
16
tests/closure/tissue1846.nim
Normal file
@@ -0,0 +1,16 @@
|
||||
type
|
||||
TBinOp*[T] = proc (x,y: T): bool
|
||||
|
||||
THeap*[T] = object
|
||||
cmp*: TBinOp[T]
|
||||
|
||||
proc less*[T](x,y: T): bool =
|
||||
x < y
|
||||
|
||||
proc initHeap*[T](cmp: TBinOp[T]): THeap[T] =
|
||||
result.cmp = cmp
|
||||
|
||||
when isMainModule:
|
||||
var h = initHeap[int](less[int])
|
||||
|
||||
echo h.cmp(2,3)
|
||||
Reference in New Issue
Block a user