DO NOT INCLUDE THIS MODULE!
This module is intended to only be used internally by trackerboy modules.
Miscellaneous utilities.
Procs
func deepEquals[T](a, b: ref T): bool
-
Deep equality test for two refs. Returns true if either:
- they are both nil
- they are not both nil and their referenced data is equivalent
Example:
var a, b: ref int assert a.deepEquals(b) # both are nil a = new(int) b = new(int) a[] = 2 b[] = 3 assert not a.deepEquals(b) # both are not nil, but the referenced data are not the same b[] = a[] assert a.deepEquals(b) # both are not nil and the referenced data are the same b = nil assert not a.deepEquals(b) # one of the refs is nil
Source Edit
Templates
template contains[T](R: typedesc[Ordinal | enum | range]; x: T): bool
-
Sugar for checking if a value is within the bounds of an ordinal type.
Example:
type IntRange = range[3..10] CharRange = range['a'..'z'] assert 5 in IntRange assert 0 notin IntRange assert 'r' in CharRange assert '9' notin CharRange
Source Edit template defaultInit(): untyped
- Alias for discard, to indicate that default initialization is intended. Source Edit
template defaultInit(someField: var typed)
- Do-nothing template that indicates that a variable was intended to be default-initialized. Source Edit