libtrackerboy/private/utils

Search:
Group by:
Source   Edit  

DO NOT INCLUDE THIS MODULE!

This module is intended to only be used internally by trackerboy modules.

take me back home ↩

Miscellaneous utilities.

Types

EqRef[T] = object
  src*: ref T                ## The source reference of the wrapper
                             ## 
  

EqRef: Deep equality ref

Ref wrapper type that changes the equality operator by testing for deep equality.

Source   Edit  

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 `==`[T](lhs, rhs: EqRef[T]): bool
Equality test using deepEquals

Example:

var a, b: EqRef[int]
assert a == b
Source   Edit  
template defaultInit(): untyped
Alias for discard, to indicate that default initialization is intended. Source   Edit  
template toEqRef[T](val: ref T): EqRef[T]
Converts a ref to an EqRef Source   Edit