diff --git a/src/libextra/serialize.rs b/src/libextra/serialize.rs index 020404057fb1..fa2737ce75f8 100644 --- a/src/libextra/serialize.rs +++ b/src/libextra/serialize.rs @@ -310,18 +310,6 @@ impl Decodable for ~str { } } -impl Encodable for @str { - fn encode(&self, s: &mut S) { - s.emit_str(*self) - } -} - -impl Decodable for @str { - fn decode(d: &mut D) -> @str { - d.read_str().to_managed() - } -} - impl Encodable for f32 { fn encode(&self, s: &mut S) { s.emit_f32(*self) diff --git a/src/libstd/at_vec.rs b/src/libstd/at_vec.rs index 55e90248e1c3..6a3c74482d35 100644 --- a/src/libstd/at_vec.rs +++ b/src/libstd/at_vec.rs @@ -338,7 +338,6 @@ mod test { assert_eq!(to_managed::([]), @[]); assert_eq!(to_managed([true]), @[true]); assert_eq!(to_managed([1, 2, 3, 4, 5]), @[1, 2, 3, 4, 5]); - assert_eq!(to_managed([@"abc", @"123"]), @[@"abc", @"123"]); assert_eq!(to_managed([@[42]]), @[@[42]]); } diff --git a/src/libstd/fmt/mod.rs b/src/libstd/fmt/mod.rs index 111eb70eb204..13e6d8080958 100644 --- a/src/libstd/fmt/mod.rs +++ b/src/libstd/fmt/mod.rs @@ -1167,7 +1167,6 @@ delegate!( u8 to Unsigned) delegate!( u16 to Unsigned) delegate!( u32 to Unsigned) delegate!( u64 to Unsigned) -delegate!(@str to String) delegate!(~str to String) delegate!(&'a str to String) delegate!(bool to Bool) diff --git a/src/libstd/path/mod.rs b/src/libstd/path/mod.rs index 11f23b22c51f..2282f97a716f 100644 --- a/src/libstd/path/mod.rs +++ b/src/libstd/path/mod.rs @@ -604,19 +604,6 @@ impl BytesContainer for ~str { fn is_str(_: Option<~str>) -> bool { true } } -impl BytesContainer for @str { - #[inline] - fn container_as_bytes<'a>(&'a self) -> &'a [u8] { - self.as_bytes() - } - #[inline] - fn container_as_str<'a>(&'a self) -> Option<&'a str> { - Some(self.as_slice()) - } - #[inline] - fn is_str(_: Option<@str>) -> bool { true } -} - impl<'a> BytesContainer for &'a [u8] { #[inline] fn container_as_bytes<'a>(&'a self) -> &'a [u8] { diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs index 707ba18378a8..b6506b517864 100644 --- a/src/libstd/path/posix.rs +++ b/src/libstd/path/posix.rs @@ -830,7 +830,6 @@ mod tests { t!(s: "a/b/c", ["d", "/e"], "/e"); t!(s: "a/b/c", ["d", "/e", "f"], "/e/f"); t!(s: "a/b/c", [~"d", ~"e"], "a/b/c/d/e"); - t!(s: "a/b/c", [@"d", @"e"], "a/b/c/d/e"); t!(v: b!("a/b/c"), [b!("d"), b!("e")], b!("a/b/c/d/e")); t!(v: b!("a/b/c"), [b!("d"), b!("/e"), b!("f")], b!("/e/f")); t!(v: b!("a/b/c"), [b!("d").to_owned(), b!("e").to_owned()], b!("a/b/c/d/e")); @@ -940,7 +939,6 @@ mod tests { t!(s: "a/b/c", ["..", "d"], "a/b/d"); t!(s: "a/b/c", ["d", "/e", "f"], "/e/f"); t!(s: "a/b/c", [~"d", ~"e"], "a/b/c/d/e"); - t!(s: "a/b/c", [@"d", @"e"], "a/b/c/d/e"); t!(v: b!("a/b/c"), [b!("d"), b!("e")], b!("a/b/c/d/e")); t!(v: b!("a/b/c"), [b!("d").to_owned(), b!("e").to_owned()], b!("a/b/c/d/e")); t!(v: b!("a/b/c"), [to_man(b!("d").to_owned()), to_man(b!("e").to_owned())], diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs index a07471afc1a6..2578acaf41cd 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -1610,7 +1610,6 @@ mod tests { t!(s: "a\\b\\c", ["d", "\\e"], "\\e"); t!(s: "a\\b\\c", ["d", "\\e", "f"], "\\e\\f"); t!(s: "a\\b\\c", [~"d", ~"e"], "a\\b\\c\\d\\e"); - t!(s: "a\\b\\c", [@"d", @"e"], "a\\b\\c\\d\\e"); t!(v: b!("a\\b\\c"), [b!("d"), b!("e")], b!("a\\b\\c\\d\\e")); t!(v: b!("a\\b\\c"), [b!("d"), b!("\\e"), b!("f")], b!("\\e\\f")); t!(v: b!("a\\b\\c"), [b!("d").to_owned(), b!("e").to_owned()], b!("a\\b\\c\\d\\e")); @@ -1755,7 +1754,6 @@ mod tests { t!(s: "a\\b\\c", ["..", "d"], "a\\b\\d"); t!(s: "a\\b\\c", ["d", "\\e", "f"], "\\e\\f"); t!(s: "a\\b\\c", [~"d", ~"e"], "a\\b\\c\\d\\e"); - t!(s: "a\\b\\c", [@"d", @"e"], "a\\b\\c\\d\\e"); t!(v: b!("a\\b\\c"), [b!("d"), b!("e")], b!("a\\b\\c\\d\\e")); t!(v: b!("a\\b\\c"), [b!("d").to_owned(), b!("e").to_owned()], b!("a\\b\\c\\d\\e")); t!(v: b!("a\\b\\c"), [to_man(b!("d").to_owned()), to_man(b!("e").to_owned())], diff --git a/src/libstd/reflect.rs b/src/libstd/reflect.rs index 87655f5911fe..d0b0f0c264d0 100644 --- a/src/libstd/reflect.rs +++ b/src/libstd/reflect.rs @@ -183,9 +183,6 @@ impl TyVisitor for MovePtrAdaptor { } fn visit_estr_box(&mut self) -> bool { - self.align_to::<@str>(); - if ! self.inner.visit_estr_box() { return false; } - self.bump_past::<@str>(); true } diff --git a/src/libstd/repr.rs b/src/libstd/repr.rs index 1ecc31ec2f4e..8ecb3395542f 100644 --- a/src/libstd/repr.rs +++ b/src/libstd/repr.rs @@ -272,10 +272,7 @@ impl<'a> TyVisitor for ReprVisitor<'a> { } fn visit_estr_box(&mut self) -> bool { - self.get::<@str>(|this, s| { - this.writer.write(['@' as u8]); - this.write_escaped_slice(*s); - }) + true } fn visit_estr_uniq(&mut self) -> bool { @@ -628,7 +625,6 @@ fn test_repr() { exact_test(&false, "false"); exact_test(&1.234, "1.234f64"); exact_test(&(&"hello"), "\"hello\""); - exact_test(&(@"hello"), "@\"hello\""); exact_test(&(~"he\u10f3llo"), "~\"he\\u10f3llo\""); exact_test(&(@10), "@10"); diff --git a/src/libstd/send_str.rs b/src/libstd/send_str.rs index 2599a74a748c..b075b75b70ac 100644 --- a/src/libstd/send_str.rs +++ b/src/libstd/send_str.rs @@ -185,7 +185,6 @@ mod tests { assert_eq!(s.len(), 5); assert_eq!(s.as_slice(), "abcde"); assert_eq!(s.to_str(), ~"abcde"); - assert!(s.equiv(&@"abcde")); assert!(s.lt(&SendStrOwned(~"bcdef"))); assert_eq!(SendStrStatic(""), Default::default()); @@ -193,7 +192,6 @@ mod tests { assert_eq!(o.len(), 5); assert_eq!(o.as_slice(), "abcde"); assert_eq!(o.to_str(), ~"abcde"); - assert!(o.equiv(&@"abcde")); assert!(o.lt(&SendStrStatic("bcdef"))); assert_eq!(SendStrOwned(~""), Default::default()); diff --git a/src/libstd/str.rs b/src/libstd/str.rs index 3cc199ce1957..5d5beb3609e8 100644 --- a/src/libstd/str.rs +++ b/src/libstd/str.rs @@ -17,46 +17,35 @@ Unicode string manipulation (`str` type) Rust's string type is one of the core primitive types of the language. While represented by the name `str`, the name `str` is not actually a valid type in Rust. Each string must also be decorated with its ownership. This means that -there are three common kinds of strings in rust: +there are two common kinds of strings in rust: * `~str` - This is an owned string. This type obeys all of the normal semantics of the `~T` types, meaning that it has one, and only one, owner. This type cannot be implicitly copied, and is moved out of when passed to other functions. -* `@str` - This is a managed string. Similarly to `@T`, this type can be - implicitly copied, and each implicit copy will increment the - reference count to the string. This means that there is no "true - owner" of the string, and the string will be deallocated when the - reference count reaches 0. - -* `&str` - Finally, this is the borrowed string type. This type of string can - only be created from one of the other two kinds of strings. As the - name "borrowed" implies, this type of string is owned elsewhere, and - this string cannot be moved out of. +* `&str` - This is the borrowed string type. This type of string can only be + created from the other kind of string. As the name "borrowed" + implies, this type of string is owned elsewhere, and this string + cannot be moved out of. As an example, here's a few different kinds of strings. ```rust -#[feature(managed_boxes)]; - fn main() { let owned_string = ~"I am an owned string"; - let managed_string = @"This string is garbage-collected"; let borrowed_string1 = "This string is borrowed with the 'static lifetime"; let borrowed_string2: &str = owned_string; // owned strings can be borrowed - let borrowed_string3: &str = managed_string; // managed strings can also be borrowed } ``` -From the example above, you can see that rust has 3 different kinds of string -literals. The owned/managed literals correspond to the owned/managed string -types, but the "borrowed literal" is actually more akin to C's concept of a -static string. +From the example above, you can see that rust has 2 different kinds of string +literals. The owned literals correspond to the owned string types, but the +"borrowed literal" is actually more akin to C's concept of a static string. -When a string is declared without a `~` or `@` sigil, then the string is -allocated statically in the rodata of the executable/library. The string then -has the type `&'static str` meaning that the string is valid for the `'static` +When a string is declared without a `~` sigil, then the string is allocated +statically in the rodata of the executable/library. The string then has the +type `&'static str` meaning that the string is valid for the `'static` lifetime, otherwise known as the lifetime of the entire program. As can be inferred from the type, these static strings are not mutable. @@ -89,11 +78,9 @@ The actual representation of strings have direct mappings to vectors: * `~str` is the same as `~[u8]` * `&str` is the same as `&[u8]` -* `@str` is the same as `@[u8]` */ -use at_vec; use cast; use cast::transmute; use char; @@ -157,16 +144,6 @@ impl<'a> ToStr for &'a str { fn to_str(&self) -> ~str { self.to_owned() } } -impl ToStr for @str { - #[inline] - fn to_str(&self) -> ~str { self.to_owned() } -} - -impl<'a> FromStr for @str { - #[inline] - fn from_str(s: &str) -> Option<@str> { Some(s.to_managed()) } -} - /// Convert a byte to a UTF-8 string /// /// # Failure @@ -1140,11 +1117,6 @@ pub mod traits { fn cmp(&self, other: &~str) -> Ordering { self.as_slice().cmp(&other.as_slice()) } } - impl TotalOrd for @str { - #[inline] - fn cmp(&self, other: &@str) -> Ordering { self.as_slice().cmp(&other.as_slice()) } - } - impl<'a> Eq for &'a str { #[inline] fn eq(&self, other: & &'a str) -> bool { @@ -1161,13 +1133,6 @@ pub mod traits { } } - impl Eq for @str { - #[inline] - fn eq(&self, other: &@str) -> bool { - eq_slice((*self), (*other)) - } - } - impl<'a> TotalEq for &'a str { #[inline] fn equals(&self, other: & &'a str) -> bool { @@ -1182,13 +1147,6 @@ pub mod traits { } } - impl TotalEq for @str { - #[inline] - fn equals(&self, other: &@str) -> bool { - eq_slice((*self), (*other)) - } - } - impl<'a> Ord for &'a str { #[inline] fn lt(&self, other: & &'a str) -> bool { self.cmp(other) == Less } @@ -1199,21 +1157,11 @@ pub mod traits { fn lt(&self, other: &~str) -> bool { self.cmp(other) == Less } } - impl Ord for @str { - #[inline] - fn lt(&self, other: &@str) -> bool { self.cmp(other) == Less } - } - impl<'a, S: Str> Equiv for &'a str { #[inline] fn equiv(&self, other: &S) -> bool { eq_slice(*self, other.as_slice()) } } - impl<'a, S: Str> Equiv for @str { - #[inline] - fn equiv(&self, other: &S) -> bool { eq_slice(*self, other.as_slice()) } - } - impl<'a, S: Str> Equiv for ~str { #[inline] fn equiv(&self, other: &S) -> bool { eq_slice(*self, other.as_slice()) } @@ -1250,16 +1198,6 @@ impl<'a> Str for ~str { fn into_owned(self) -> ~str { self } } -impl<'a> Str for @str { - #[inline] - fn as_slice<'a>(&'a self) -> &'a str { - let s: &'a str = *self; s - } - - #[inline] - fn into_owned(self) -> ~str { self.to_owned() } -} - impl<'a> Container for &'a str { #[inline] fn len(&self) -> uint { @@ -1272,11 +1210,6 @@ impl Container for ~str { fn len(&self) -> uint { self.as_slice().len() } } -impl Container for @str { - #[inline] - fn len(&self) -> uint { self.as_slice().len() } -} - impl Mutable for ~str { /// Remove all content, make the string empty #[inline] @@ -1734,9 +1667,6 @@ pub trait StrSlice<'a> { /// Copy a slice into a new owned str. fn to_owned(&self) -> ~str; - /// Copy a slice into a new managed str. - fn to_managed(&self) -> @str; - /// Converts to a vector of `u16` encoded as UTF-16. fn to_utf16(&self) -> ~[u16]; @@ -2246,14 +2176,6 @@ impl<'a> StrSlice<'a> for &'a str { } } - #[inline] - fn to_managed(&self) -> @str { - unsafe { - let v: *&[u8] = cast::transmute(self); - cast::transmute(at_vec::to_managed(*v)) - } - } - fn to_utf16(&self) -> ~[u16] { let mut u = ~[]; for ch in self.chars() { @@ -2682,20 +2604,6 @@ impl DeepClone for ~str { } } -impl Clone for @str { - #[inline] - fn clone(&self) -> @str { - *self - } -} - -impl DeepClone for @str { - #[inline] - fn deep_clone(&self) -> @str { - *self - } -} - impl FromIterator for ~str { #[inline] fn from_iterator>(iterator: &mut T) -> ~str { @@ -2727,10 +2635,6 @@ impl Default for ~str { fn default() -> ~str { ~"" } } -impl Default for @str { - fn default() -> @str { @"" } -} - #[cfg(test)] mod tests { use iter::AdditiveIterator; @@ -3536,12 +3440,6 @@ mod tests { assert_eq!("\U0001d4ea\r".escape_default(), ~"\\U0001d4ea\\r"); } - #[test] - fn test_to_managed() { - assert_eq!("abc".to_managed(), @"abc"); - assert_eq!("abcdef".slice(1, 5).to_managed(), @"bcde"); - } - #[test] fn test_total_ord() { "1234".cmp(& &"123") == Greater; @@ -3584,10 +3482,8 @@ mod tests { ); t!("foo", "bar", "foobar"); - t!("foo", @"bar", "foobar"); t!("foo", ~"bar", "foobar"); t!("ศไทย中", "华Việt Nam", "ศไทย中华Việt Nam"); - t!("ศไทย中", @"华Việt Nam", "ศไทย中华Việt Nam"); t!("ศไทย中", ~"华Việt Nam", "ศไทย中华Việt Nam"); } @@ -3874,7 +3770,6 @@ mod tests { } t::<&str>(); - t::<@str>(); t::<~str>(); } @@ -3886,7 +3781,6 @@ mod tests { let s = ~"01234"; assert_eq!(5, sum_len(["012", "", "34"])); - assert_eq!(5, sum_len([@"01", @"2", @"34", @""])); assert_eq!(5, sum_len([~"01", ~"2", ~"34", ~""])); assert_eq!(5, sum_len([s.as_slice()])); } @@ -3957,8 +3851,6 @@ mod tests { fn test_from_str() { let owned: Option<~str> = from_str(&"string"); assert_eq!(owned, Some(~"string")); - let managed: Option<@str> = from_str(&"string"); - assert_eq!(managed, Some(@"string")); } } diff --git a/src/libstd/to_bytes.rs b/src/libstd/to_bytes.rs index 8df028f56d50..7ca1590dad07 100644 --- a/src/libstd/to_bytes.rs +++ b/src/libstd/to_bytes.rs @@ -288,13 +288,6 @@ impl IterBytes for ~str { } } -impl IterBytes for @str { - #[inline] - fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { - self.as_slice().iter_bytes(lsb0, f) - } -} - impl IterBytes for Option { #[inline] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { diff --git a/src/libstd/to_str.rs b/src/libstd/to_str.rs index a58b09d8ecde..edbf33144177 100644 --- a/src/libstd/to_str.rs +++ b/src/libstd/to_str.rs @@ -195,7 +195,6 @@ mod tests { assert_eq!(false.to_str(), ~"false"); assert_eq!(().to_str(), ~"()"); assert_eq!((~"hi").to_str(), ~"hi"); - assert_eq!((@"hi").to_str(), ~"hi"); } #[test] diff --git a/src/libstd/unstable/raw.rs b/src/libstd/unstable/raw.rs index 8aee26c24b29..c568edd09d1d 100644 --- a/src/libstd/unstable/raw.rs +++ b/src/libstd/unstable/raw.rs @@ -59,7 +59,6 @@ impl Repr<*Box> for @T {} impl Repr<*Box>> for @[T] {} impl Repr<*Vec> for ~[T] {} impl Repr<*String> for ~str {} -impl Repr<*Box> for @str {} // sure would be nice to have this // impl Repr<*Vec> for ~[T] {}