You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey! I'm a new user to this crate, and while reading through the docs I noticed that the first example here seems to have a bad edge case when the returned slice should be empty. This can occur if the imput slice was empty or all to_trim. For the empty input the function craches and for the other case a wrong range still containing a value that should be trimmed is returned.
I think the easiest fix is replacing the last two lines of the function body by this:
let back = bits.iter().by_ref().rposition(stop).map_or(0, |p| p + 1);&bits[front..back]
This is not a very big deal but it's always nice when the examples actually work 🙂.
The text was updated successfully, but these errors were encountered:
Embarassing. Your issue was immediately followed by #114, which is also about my difficult relationship with off-by-one errors when walking a slice backwards.
Hey! I'm a new user to this crate, and while reading through the docs I noticed that the first example here seems to have a bad edge case when the returned slice should be empty. This can occur if the imput slice was empty or all
to_trim
. For the empty input the function craches and for the other case a wrong range still containing a value that should be trimmed is returned.I think the easiest fix is replacing the last two lines of the function body by this:
This is not a very big deal but it's always nice when the examples actually work 🙂.
The text was updated successfully, but these errors were encountered: