Which makes me wonder :
1/ could you build the same unsafe behiavor in Rust if you wanted to by not specifying lifetime constraints ?
2/ If yes, shouldn't lifetime constraints be mandatory ?
1/ could you build the same unsafe behiavor in Rust if you wanted to by not specifying lifetime constraints ?
2/ If yes, shouldn't lifetime constraints be mandatory ?
http://play.rust-lang.org/?run=1&code=enum%20Token%20{%0A%20...
The tokenization function itself doesn't have to explicitly specify lifetimes like it does in the blog post. It would also work without them and Rust would still ensure that you don't end up with a use-after-free.