Hi, thanks for your great contribution to this project first.
However, we have found a simple unsound problem in Corpus.
The function Corpus::ngram_from_id is actually 'unsafe' since it does not validate the ngram_id is valid.
Suggestions
Here are some action choices we suggested:
Mark this function as 'unsafe' so that it would pass the responsibility of ensuring the ngram_id to its caller.
(recommended) Add assert! or at least debug_assert! macros before calling get_unchecked.
Hi, thanks for your great contribution to this project first.
However, we have found a simple unsound problem in
Corpus
. The functionCorpus::ngram_from_id
is actually 'unsafe' since it does not validate thengram_id
is valid.Suggestions
Here are some action choices we suggested:
ngram_id
to its caller.assert!
or at leastdebug_assert!
macros before callingget_unchecked
.