]> git.lizzy.rs Git - rust.git/commit
str: Add method .into_owned(self) -> ~str to Str
authorKevin Ballard <kevin@sb.org>
Thu, 1 Aug 2013 22:54:58 +0000 (15:54 -0700)
committerKevin Ballard <kevin@sb.org>
Thu, 1 Aug 2013 22:54:58 +0000 (15:54 -0700)
commitaa94dfa625e0d19cd322d7816167486ece53397d
tree7e1a470d8d4fbd0d06a5adc6ab12e8533460835a
parent82b24559e6aa0914f8a49e0a9dbfb3cf35372515
str: Add method .into_owned(self) -> ~str to Str

The method .into_owned() is meant to be used as an optimization when you
need to get a ~str from a Str, but don't want to unnecessarily copy it
if it's already a ~str.

This is meant to ease functions that look like

  fn foo<S: Str>(strs: &[S])

Previously they could work with the strings as slices using .as_slice(),
but producing ~str required copying the string, even if the vector
turned out be a &[~str] already.
src/libstd/str.rs