Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import
- sets
- type
- AlwaysMatch = object
- proc match(val: string, values: HashSet[string]): bool =
- val in values
- proc match(val: string, predicate: proc(x: string): bool): bool =
- predicate(val)
- template match(val: string, T: type AlwaysMatch): bool =
- true
- proc walkDirRec(filter: auto = AlwaysMatch) =
- mixin match
- if match("dir_name", filter):
- echo "we have a match"
- else:
- echo "no match"
- walkDirRec toHashSet(["foo", "bar", "baz"])
- walkDirRec toHashSet(["file_name", "dir_name"])
- walkDirRec()
- walkDirRec do (x: string) -> bool:
- echo "matching ", x
- return true
- walkDirRec do (x: string) -> bool:
- echo "matching ", x
- return false
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement