Translating C++ code


C++ code
Rust code


Please post a litte bit more info next time. Not everyone knows you already posted on internals. Also some info surrounding your code would be helpful. Like what errors do you get, what are you expecting.

You almost had it. The second lifetime 'b was unnecessary, you can re-use the lifetime 'afor multiple reference arguments to a function. See PlayPen.


but you changed Token struct, what if it is from library and I can not change it?


That is exactly why you should be providing more information than just some code :wink:

You can simply change the function to return a Token<'a, 'a>: PlayPen


big thanks, it works