What's the difference between alloc :: rc :: Rc and std :: rc :: Rc?

I'm curious if there is any difference between these two modules in practice? And if not, why are these two duplicates then?

+3


source to share


1 answer


std::rc::Rc

is just a re-export alloc::rc::Rc

. You can see in src / std / lib.rs that the entire module is rc

re-exported:pub use alloc::rc;



The box alloc

is for any memory allocation. Link counted, boxed, original allocators and shared to the underlying allocator (often jemalloc

in Rust). Since the type rc

is such a common type that it must exist in the standard library, but the box alloc

must not be part of the standard library, only the module is relayed rc

alloc

to the standard library. This saves the user from having to worry about the box alloc

and instead offers a clean standard library without unnecessary things that might be awkward to use.

+7


source







All Articles