Skip to content

Commit ba707fb

Browse files
aochagaviaalexcrichton
authored andcommitted
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 482c776 commit ba707fb

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
@@ -603,11 +603,6 @@ pub mod raw {
603603
from_utf8_owned(vec![u])
604604
}
605605

606-
/// Sets the length of a string
607-
///
608-
/// This will explicitly set the size of the string, without actually
609-
/// modifying its buffers, so it is up to the caller to ensure that
610-
/// the string is actually the specified size.
611606
#[test]
612607
fn test_from_buf_len() {
613608
use slice::ImmutableVector;
@@ -785,30 +780,6 @@ impl<'a> StrAllocating for &'a str {
785780
}
786781
}
787782

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