[−][src]Function kul::source_stream::to_rc_str
pub fn to_rc_str(s: String) -> Rc<str>
Converting a String
to an Rc<str>
slice (which is also "boxed",
i.e. heap-allocated) has the benefits of:
-
Always freeing the
String
's unused capacity, which might be important if you keep many of these alive. -
Minimizing pointer indirection to only the one level that is an
Rc
pointing at a heap block, which might be important for cache locality.
However, this conversion always has the one-time cost of moving the string
contents into the new Rc
allocation.