3 ms·
cast both of those as_ptr()s to usize and this does what you want.
by steveklabnik 6y ago
cast both of those as_ptr()s to usize and this does what you want.
- defen 6y agoI know it's just an example, but in case anyone tries to grab the code - it's worth noting that this will panic if you try to slice into the middle of a UTF-8 sequence, and will give byte offsets and not char offsets, so it might not give the answer you expect if src contains multibyte chars before tok. Also I'm fairly new to Rust so it's possible there's some other way to do it that I just don't know about.