Skip to content

Commit 347383b

Browse files
committed
Remove OwnedStr trait
This trait was only implemented by `String`. It provided the methods `into_bytes` and `append`, both of which **are already implemented as normal methods** of `String` (not as trait methods). This change improves the consistency of strings. This shouldn't break any code, except if somebody has implemented `OwnedStr` for a user-defined type.
1 parent 2ffccb7 commit 347383b

File tree

4 files changed

+2
-35
lines changed

4 files changed

+2
-35
lines changed

src/libcollections/str.rs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -601,11 +601,6 @@ pub mod raw {
601601
from_utf8_owned(vec![u])
602602
}
603603

604-
/// Sets the length of a string
605-
///
606-
/// This will explicitly set the size of the string, without actually
607-
/// modifying its buffers, so it is up to the caller to ensure that
608-
/// the string is actually the specified size.
609604
#[test]
610605
fn test_from_buf_len() {
611606
use slice::ImmutableVector;
@@ -783,30 +778,6 @@ impl<'a> StrAllocating for &'a str {
783778
}
784779
}
785780

786-
/// Methods for owned strings
787-
pub trait OwnedStr {
788-
/// Consumes the string, returning the underlying byte buffer.
789-
///
790-
/// The buffer does not have a null terminator.
791-
fn into_bytes(self) -> Vec<u8>;
792-
793-
/// Pushes the given string onto this string, returning the concatenation of the two strings.
794-
fn append(self, rhs: &str) -> String;
795-
}
796-
797-
impl OwnedStr for String {
798-
#[inline]
799-
fn into_bytes(self) -> Vec<u8> {
800-
unsafe { mem::transmute(self) }
801-
}
802-
803-
#[inline]
804-
fn append(mut self, rhs: &str) -> String {
805-
self.push_str(rhs);
806-
self
807-
}
808-
}
809-
810781
#[cfg(test)]
811782
mod tests {
812783
use std::iter::AdditiveIterator;

src/libstd/ascii.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use iter::Iterator;
2020
use mem;
2121
use option::{Option, Some, None};
2222
use slice::{ImmutableVector, MutableVector, Vector};
23-
use str::{OwnedStr, Str, StrAllocating, StrSlice};
23+
use str::{Str, StrAllocating, StrSlice};
2424
use string::String;
2525
use to_string::IntoStr;
2626
use vec::Vec;

src/libstd/os.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ use vec::Vec;
5656
use c_str::ToCStr;
5757
#[cfg(unix)]
5858
use libc::c_char;
59-
#[cfg(windows)]
60-
use str::OwnedStr;
6159

6260
/// Get the number of cores available
6361
pub fn num_cpus() -> uint {
@@ -708,8 +706,6 @@ pub fn self_exe_name() -> Option<Path> {
708706

709707
#[cfg(windows)]
710708
fn load_self() -> Option<Vec<u8>> {
711-
use str::OwnedStr;
712-
713709
unsafe {
714710
use os::win32::fill_utf16_buf_and_decode;
715711
fill_utf16_buf_and_decode(|buf, sz| {

src/libstd/prelude.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
#[doc(no_inline)] pub use path::{GenericPath, Path, PosixPath, WindowsPath};
7777
#[doc(no_inline)] pub use ptr::RawPtr;
7878
#[doc(no_inline)] pub use io::{Buffer, Writer, Reader, Seek};
79-
#[doc(no_inline)] pub use str::{Str, StrVector, StrSlice, OwnedStr};
79+
#[doc(no_inline)] pub use str::{Str, StrVector, StrSlice};
8080
#[doc(no_inline)] pub use str::{IntoMaybeOwned, StrAllocating, UnicodeStrSlice};
8181
#[doc(no_inline)] pub use to_string::{ToString, IntoStr};
8282
#[doc(no_inline)] pub use tuple::{Tuple1, Tuple2, Tuple3, Tuple4};

0 commit comments

Comments
 (0)