Hacker News new | past | comments | ask | show | jobs | submit login

On the contrary, it's actually rather easy to use the type checker to encode this: Just make a wrapper type CharIdx(usize) that encodes the fact that the enclosed value is a valid char position and implement Index for it using unchecked indexing. Also implement Index for usize with the usual check for bounds and valid character position.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: