Confuse by Rc doc

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>>

Yup!

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

2 Likes

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

No

Choosing your Guarantees covers the costs of these.