[][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:

  1. Always freeing the String's unused capacity, which might be important if you keep many of these alive.

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