Earlier quoted context omitted.
The standard C++ way to free resources is the character '}'
Tell that to the enormous heap object you just forgot you made earlier.
My favorite Rust function
11–20 of 197 posts
Re: My favorite Rust function
#12Re: My favorite Rust function
#13Earlier quoted context omitted.
The standard C++ way to free resources is the character '}'
Rust has the exact same semantics there. Drop is useful when you need to explicitly notate that a value should end its life early.
Would do the same in C++ for values held by unique_ptr: take ownership of the pointer and then free it.
Re: My favorite Rust function
#14Earlier quoted context omitted.
Rust has the exact same semantics there. Drop is useful when you need to explicitly notate that a value should end its life early.
void drop(unique_ptr && x) {} Would do the same in C++ for values held by unique_ptr: take ownership of the pointer and then free it.
Re: My favorite Rust function
#15I just spit mezcal on a stranger.
Re: My favorite Rust function
#16If I do the rust equivalent of:
def add1(x):
return x + 1
x = 1
y = add1(x)
z = add1(x)
then will x have been deallocated by the first call to add1 and will the second call to add1 fail?[You can ignore the fact that I'm using numbers and substitute an object if that makes more sense in the context of allocating / deallocating memory in rust.]
Re: My favorite Rust function
#17Re: My favorite Rust function
#18I haven't used rust, so can you explain this to me: If I do the rust equivalent of: def add1(x): return x + 1 x = 1 y = add1(x) z = add1(x) then will x have been deallocated by the first call to add1 and will the second call to add1 fail? [You can ignore the fact that I'm using numbers and substitute an object if that makes more sense in the context of allocating / deallocating memory in rust.]
Re: My favorite Rust function
#19Gotta admit, that really is a cute example. However, I was a bit surprised when the author described Go as "unacceptably crippled." What is he referring to?
Re: My favorite Rust function
#20> unacceptably crippled like Go I just spit mezcal on a stranger.