Confuse by Rc doc


#1

Rc Officail doc say:
The type Rc provides shared ownership of a value of type T, allocated in the heap.

If I have a struct ‘Person’, when I write

Rc<Person>

the Person is always allocate in the heap automatically via Rc::new()?
But what is different to the

Rc<Box<Person>>

#2

Yup!

That would allocate a pointer on the heap, and that pointer would point to a Person elsewhere on the heap.


#3

And Refcell::new is always allocate in the heap?


#4

No


#5

https://doc.rust-lang.org/beta/book/choosing-your-guarantees.html covers the costs of these.