Re:My favorite Rust function
by Filligree on Saturday October 12, 2019 @07:50PM
(#21237176)
You'll get a compile-time error explaining the situation, yes, including documentation links and possible fixes. The differences between the versions are minimal.
This works on the assumption that whatever "+ 1" really means doesn't itself need ownership of x, e.g. because it mutates it. If it does, then you'll get an error. Or you could do this:
Which, presumably, modifies x instead of returning a copy. It's your job to make sure it makes sense to do that, but Rust has another trick in its pockets:
[ Parent
| on HN ]
There are no comments on this comment yet.