Похожие чаты

Why does Rc has to store data on heap?

4 ответов

18 просмотров

well, if it were on stack, then you wouldn't be able to do this: let foo = Rc::new(42); let bar = Rc::clone(&foo); drop(foo); assert_eq!(*bar, 42);

// AlenPaulVarghese //
what about Arc

same thing? the only difference is that Arc uses atomic operations for counting references, while Rc doesn't

// AlenPaulVarghese //- Автор вопроса

Похожие вопросы

Обсуждают сегодня

Карта сайта