8 ms·
The complicated lifetime stuff is pretty rare to run into unless you are doing some tricky things, like custom zero copy parsers or data structures or whatever.
by kazagistar 10y ago
The complicated lifetime stuff is pretty rare to run into unless you are doing some tricky things, like custom zero copy parsers or data structures or whatever.
The most important tricks I've learned are:
- Return types should usually be owned values, input types should often be references (or AsRefs). "Be explicit in what you return, and general in what you accept".
- If I'm going to be pointing into an array, its often easier to just pass around indexes instead.
- zardeh 10y agoYeah I learned to return values and accept references very quickly, had to entirely refactor my learning project a day or so into it, but that was for the best.