Translating C++ code


#1

C++ code http://cpp.sh/3sbc
Rust code http://is.gd/q0D9xk


#2

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.


#3

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


#4

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


#5

big thanks, it works