this should technically only be executed in non-release.
```D
version(assert)
    if (needle.empty)
        onRangeError("Cannot count occurrences of an empty range");
```