mattaylor/elvis

Cleanup for nilable types

geekrelief opened this issue · 1 comments

elvis/elvis.nim

Lines 20 to 23 in 1ad14f1

template truthy*[T](val: ref T): bool = not val.isNil
template truthy*[T](val: ptr T): bool = not val.isNil
template truthy*(val: pointer): bool = not val.isNil
template truthy*(val: ref | ptr | pointer): bool = not val.isNil

We only need the last line with the typeclass. It's equivalent to the top three. https://nim-lang.github.io/Nim/manual.html#generics-type-classes

done