2 ms·
They are both pointers, but `b` is an owned pointer (it "owns" a heap allocated value) and `r` is a borrowed/reference pointer (a "pure" reference to something
by Crespyl 9y ago
They are both pointers, but `b` is an owned pointer (it "owns" a heap allocated value) and `r` is a borrowed/reference pointer (a "pure" reference to something (heap or stack) that it doesn't own and isn't responsible for).
`b` cannot be moved, mutated, or deallocated until `r` is gone. When `b` goes out of scope the heap value it points to will be automatically deallocated, unless `r` still exists somewhere (saved off in a struct for example), in which case the program won't compile.