Skip to content

Replace StrAllocating.into_owned() with .into_string() #14510

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 30, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/libregex/re.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,13 +573,13 @@ impl<'t> Replacer for NoExpand<'t> {

impl<'t> Replacer for &'t str {
fn reg_replace<'a>(&'a mut self, caps: &Captures) -> MaybeOwned<'a> {
Owned(caps.expand(*self).into_owned())
Owned(caps.expand(*self))
}
}

impl<'a> Replacer for |&Captures|: 'a -> String {
fn reg_replace<'r>(&'r mut self, caps: &Captures) -> MaybeOwned<'r> {
Owned((*self)(caps).into_owned())
Owned((*self)(caps))
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ impl fmt::Show for clean::Type {
}
}
}
ret.into_owned()
ret
})
}
clean::Proc(ref decl) => {
Expand Down
32 changes: 16 additions & 16 deletions src/libstd/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ use mem;
use option::{None, Option, Some};
use result::Result;
use slice::Vector;
use slice::{ImmutableVector, MutableVector, CloneableVector};
use slice::{ImmutableVector, MutableVector};
use string::String;
use vec::Vec;

Expand Down Expand Up @@ -503,7 +503,7 @@ pub fn from_utf8_lossy<'a>(v: &'a [u8]) -> MaybeOwned<'a> {
res.push_bytes(v.slice(subseqidx, total))
};
}
Owned(res.into_owned())
Owned(res.into_string())
}

/*
Expand Down Expand Up @@ -608,7 +608,7 @@ impl<'a> Str for MaybeOwned<'a> {

impl<'a> StrAllocating for MaybeOwned<'a> {
#[inline]
fn into_owned(self) -> String {
fn into_string(self) -> String {
match self {
Slice(s) => s.to_string(),
Owned(s) => s
Expand Down Expand Up @@ -723,18 +723,18 @@ Section: Trait implementations
/// Any string that can be represented as a slice
pub trait StrAllocating: Str {
/// Convert `self` into a `String`, not making a copy if possible.
fn into_owned(self) -> String;
fn into_string(self) -> String;

/// Convert `self` into a `String`.
#[inline]
fn to_string(&self) -> String {
String::from_str(self.as_slice())
}

/// Convert `self` into a `String`, not making a copy if possible.
#[inline]
fn into_string(self) -> String {
self.into_owned()
#[allow(missing_doc)]
#[deprecated = "replaced by .into_string()"]
fn into_owned(self) -> String {
self.into_string()
}

/// Escape each char in `s` with `char::escape_default`.
Expand Down Expand Up @@ -889,7 +889,7 @@ pub trait StrAllocating: Str {

impl<'a> StrAllocating for &'a str {
#[inline]
fn into_owned(self) -> String {
fn into_string(self) -> String {
self.to_string()
}
}
Expand Down Expand Up @@ -1045,7 +1045,7 @@ mod tests {
#[test]
fn test_concat() {
fn t(v: &[String], s: &str) {
assert_eq!(v.concat(), s.to_str().into_owned());
assert_eq!(v.concat(), s.to_str().into_string());
}
t(["you".to_string(), "know".to_string(), "I'm".to_string(),
"no".to_string(), "good".to_string()], "youknowI'mnogood");
Expand All @@ -1057,7 +1057,7 @@ mod tests {
#[test]
fn test_connect() {
fn t(v: &[String], sep: &str, s: &str) {
assert_eq!(v.connect(sep), s.to_str().into_owned());
assert_eq!(v.connect(sep), s.to_str().into_string());
}
t(["you".to_string(), "know".to_string(), "I'm".to_string(),
"no".to_string(), "good".to_string()],
Expand All @@ -1070,7 +1070,7 @@ mod tests {
#[test]
fn test_concat_slices() {
fn t(v: &[&str], s: &str) {
assert_eq!(v.concat(), s.to_str().into_owned());
assert_eq!(v.concat(), s.to_str().into_string());
}
t(["you", "know", "I'm", "no", "good"], "youknowI'mnogood");
let v: &[&str] = [];
Expand All @@ -1081,7 +1081,7 @@ mod tests {
#[test]
fn test_connect_slices() {
fn t(v: &[&str], sep: &str, s: &str) {
assert_eq!(v.connect(sep), s.to_str().into_owned());
assert_eq!(v.connect(sep), s.to_str().into_string());
}
t(["you", "know", "I'm", "no", "good"],
" ", "you know I'm no good");
Expand Down Expand Up @@ -2162,9 +2162,9 @@ mod tests {
}

#[test]
fn test_maybe_owned_into_owned() {
assert_eq!(Slice("abcde").into_owned(), "abcde".to_string());
assert_eq!(Owned("abcde".to_string()).into_owned(), "abcde".to_string());
fn test_maybe_owned_into_string() {
assert_eq!(Slice("abcde").into_string(), "abcde".to_string());
assert_eq!(Owned("abcde".to_string()).into_string(), "abcde".to_string());
}

#[test]
Expand Down
5 changes: 0 additions & 5 deletions src/libstd/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,6 @@ impl Str for String {
}

impl StrAllocating for String {
#[inline]
fn into_owned(self) -> String {
self
}

#[inline]
fn into_string(self) -> String {
self
Expand Down