summary refs log tree commit diff stats
path: root/tests/concepts/t3414.nim
blob: d45973034ef3507653c92866250b8e5778d2de73 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
type
  View[T] = concept v
    v.empty is bool
    v.front is T
    popFront v

proc find(view: View; target: View.T): View =
  result = view

  while not result.empty:
    if view.front == target:
      return

    mixin popFront
    popFront result

proc popFront[T](s: var seq[T]) = discard
proc empty[T](s: seq[T]): bool = false

var s1 = @[1, 2, 3]
let s2 = s1.find(10)