3 ms·
The nickname works like alias that only shows 3 characters of the name. Before using nickname the code frees the name making both name and nickname invalid. The
by takeda 7y ago
The nickname works like alias that only shows 3 characters of the name. Before using nickname the code frees the name making both name and nickname invalid.
The error here is use after free and one strengths of rust is to detect errors like this.
In C such code would compile, what's worse, it would work and behave correctly most of the time. If your code was more complex (for example using threads) you would get a bug that the code would work fine most of the time, but once in a while it would display garbage.