Quick actions

cmd+k|ctrl+k

Navigation

Languages

Untitled

Snippet info

Language

Nim

Visibility

unlisted

Author

legacy-anonymous

Created

2018-05-07T19:36:05Z

Updated

2018-05-07T19:36:05Z


proc `==`*[T: StringSlice or string](str: StringSlice, cmp: T): bool =
  if cmp.isNil():        return false
  if str.len != cmp.len: return false
  when T is StringSlice:
    for i in cmp.start..cmp.stop:
      if str.str[i + str.start] != cmp.str[i]: return false
    return true
  else:
    return str.startsWith(cmp)

template `==`*(str: string, cmp: StringSlice): bool =
  cmp == str
INFO