about summary refs log tree commit diff
path: root/src/libcore/str.rs
diff options
context:
space:
mode:
authorMichael Sullivan <sully@msully.net>2012-06-25 20:00:46 -0700
committerMichael Sullivan <sully@msully.net>2012-06-25 20:00:46 -0700
commit329eca6044fdf376a7a89ec7a96dba7a8b884cf7 (patch)
tree7008814278a066914b6ba36818388d5212ffda9f /src/libcore/str.rs
parentc087aaf56b1109163126fea4c2760f8414ffbe56 (diff)
downloadrust-329eca6044fdf376a7a89ec7a96dba7a8b884cf7.tar.gz
rust-329eca6044fdf376a7a89ec7a96dba7a8b884cf7.zip
Make vectors uglier ([]/~). Sorry. Should be temporary. Closes #2725.
Diffstat (limited to 'src/libcore/str.rs')
-rw-r--r--src/libcore/str.rs253
1 files changed, 127 insertions, 126 deletions
diff --git a/src/libcore/str.rs b/src/libcore/str.rs
index 7b64f6da0bb..63d833e197f 100644
--- a/src/libcore/str.rs
+++ b/src/libcore/str.rs
@@ -122,7 +122,7 @@ Convert a vector of bytes to a UTF-8 string
 
 Fails if invalid UTF-8
 "]
-pure fn from_bytes(vv: [u8]) -> str {
+pure fn from_bytes(vv: [u8]/~) -> str {
     assert is_utf8(vv);
     ret unsafe { unsafe::from_bytes(vv) };
 }
@@ -136,7 +136,7 @@ Fails if invalid UTF-8
 "]
 pure fn from_byte(b: u8) -> str {
     assert b < 128u8;
-    let mut v = [b, 0u8];
+    let mut v = [b, 0u8]/~;
     unsafe { ::unsafe::transmute(v) }
 }
 
@@ -209,7 +209,7 @@ fn push_char(&s: str, ch: char) {
         }
 
         as_bytes(s) {|bytes|
-            let mut mut_bytes: [u8] = ::unsafe::reinterpret_cast(bytes);
+            let mut mut_bytes: [u8]/~ = ::unsafe::reinterpret_cast(bytes);
             vec::unsafe::set_len(mut_bytes, new_len + 1u);
             ::unsafe::forget(mut_bytes);
         }
@@ -322,10 +322,10 @@ Converts a string to a vector of bytes
 
 The result vector is not null-terminated.
 "]
-pure fn bytes(s: str) -> [u8] {
+pure fn bytes(s: str) -> [u8]/~ {
     unsafe {
         let mut s_copy = s;
-        let mut v: [u8] = ::unsafe::transmute(s_copy);
+        let mut v: [u8]/~ = ::unsafe::transmute(s_copy);
         vec::unsafe::set_len(v, len(s));
         ret v;
     }
@@ -342,12 +342,12 @@ pure fn byte_slice<T>(s: str/&, f: fn([u8]/&) -> T) -> T {
 }
 
 #[doc = "Convert a string to a vector of characters"]
-pure fn chars(s: str/&) -> [char] {
-    let mut buf = [], i = 0u;
+pure fn chars(s: str/&) -> [char]/~ {
+    let mut buf = []/~, i = 0u;
     let len = len(s);
     while i < len {
         let {ch, next} = char_range_at(s, i);
-        buf += [ch];
+        buf += [ch]/~;
         i = next;
     }
     ret buf;
@@ -378,7 +378,7 @@ pure fn slice(s: str/&, begin: uint, end: uint) -> str {
 #[doc = "
 Splits a string into substrings at each occurrence of a given character
 "]
-pure fn split_char(s: str/&, sep: char) -> [str] {
+pure fn split_char(s: str/&, sep: char) -> [str]/~ {
     split_char_inner(s, sep, len(s), true)
 }
 
@@ -388,27 +388,27 @@ character up to 'count' times
 
 The byte must be a valid UTF-8/ASCII byte
 "]
-pure fn splitn_char(s: str/&, sep: char, count: uint) -> [str] {
+pure fn splitn_char(s: str/&, sep: char, count: uint) -> [str]/~ {
     split_char_inner(s, sep, count, true)
 }
 
 #[doc = "
 Like `split_char`, but omits empty strings from the returned vector
 "]
-pure fn split_char_nonempty(s: str/&, sep: char) -> [str] {
+pure fn split_char_nonempty(s: str/&, sep: char) -> [str]/~ {
     split_char_inner(s, sep, len(s), false)
 }
 
 pure fn split_char_inner(s: str/&, sep: char, count: uint, allow_empty: bool)
-    -> [str] {
+    -> [str]/~ {
     if sep < 128u as char {
         let b = sep as u8, l = len(s);
-        let mut result = [], done = 0u;
+        let mut result = []/~, done = 0u;
         let mut i = 0u, start = 0u;
         while i < l && done < count {
             if s[i] == b {
                 if allow_empty || start < i {
-                    result += [unsafe { unsafe::slice_bytes(s, start, i) }];
+                    result += [unsafe { unsafe::slice_bytes(s, start, i) }]/~;
                 }
                 start = i + 1u;
                 done += 1u;
@@ -416,7 +416,7 @@ pure fn split_char_inner(s: str/&, sep: char, count: uint, allow_empty: bool)
             i += 1u;
         }
         if allow_empty || start < l {
-            result += [unsafe { unsafe::slice_bytes(s, start, l) }];
+            result += [unsafe { unsafe::slice_bytes(s, start, l) }]/~;
         }
         result
     } else {
@@ -426,7 +426,7 @@ pure fn split_char_inner(s: str/&, sep: char, count: uint, allow_empty: bool)
 
 
 #[doc = "Splits a string into substrings using a character function"]
-pure fn split(s: str/&, sepfn: fn(char) -> bool) -> [str] {
+pure fn split(s: str/&, sepfn: fn(char) -> bool) -> [str]/~ {
     split_inner(s, sepfn, len(s), true)
 }
 
@@ -434,24 +434,24 @@ pure fn split(s: str/&, sepfn: fn(char) -> bool) -> [str] {
 Splits a string into substrings using a character function, cutting at
 most `count` times.
 "]
-pure fn splitn(s: str/&, sepfn: fn(char) -> bool, count: uint) -> [str] {
+pure fn splitn(s: str/&, sepfn: fn(char) -> bool, count: uint) -> [str]/~ {
     split_inner(s, sepfn, count, true)
 }
 
 #[doc = "Like `split`, but omits empty strings from the returned vector"]
-pure fn split_nonempty(s: str/&, sepfn: fn(char) -> bool) -> [str] {
+pure fn split_nonempty(s: str/&, sepfn: fn(char) -> bool) -> [str]/~ {
     split_inner(s, sepfn, len(s), false)
 }
 
 pure fn split_inner(s: str/&, sepfn: fn(cc: char) -> bool, count: uint,
-               allow_empty: bool) -> [str] {
+               allow_empty: bool) -> [str]/~ {
     let l = len(s);
-    let mut result = [], i = 0u, start = 0u, done = 0u;
+    let mut result = []/~, i = 0u, start = 0u, done = 0u;
     while i < l && done < count {
         let {ch, next} = char_range_at(s, i);
         if sepfn(ch) {
             if allow_empty || start < i {
-                result += [unsafe { unsafe::slice_bytes(s, start, i) }];
+                result += [unsafe { unsafe::slice_bytes(s, start, i) }]/~;
             }
             start = next;
             done += 1u;
@@ -459,7 +459,7 @@ pure fn split_inner(s: str/&, sepfn: fn(cc: char) -> bool, count: uint,
         i = next;
     }
     if allow_empty || start < l {
-        result += [unsafe { unsafe::slice_bytes(s, start, l) }];
+        result += [unsafe { unsafe::slice_bytes(s, start, l) }]/~;
     }
     result
 }
@@ -510,19 +510,19 @@ Splits a string into a vector of the substrings separated by a given string
 assert [\"\", \"XXX\", \"YYY\", \"\"] == split_str(\".XXX.YYY.\", \".\")
 ~~~
 "]
-pure fn split_str(s: str/&a, sep: str/&b) -> [str] {
-    let mut result = [];
+pure fn split_str(s: str/&a, sep: str/&b) -> [str]/~ {
+    let mut result = []/~;
     iter_between_matches(s, sep) {|from, to|
-        unsafe { result += [unsafe::slice_bytes(s, from, to)]; }
+        unsafe { result += [unsafe::slice_bytes(s, from, to)]/~; }
     }
     result
 }
 
-pure fn split_str_nonempty(s: str/&a, sep: str/&b) -> [str] {
-    let mut result = [];
+pure fn split_str_nonempty(s: str/&a, sep: str/&b) -> [str]/~ {
+    let mut result = []/~;
     iter_between_matches(s, sep) {|from, to|
         if to > from {
-            unsafe { result += [unsafe::slice_bytes(s, from, to)]; }
+            unsafe { result += [unsafe::slice_bytes(s, from, to)]/~; }
         }
     }
     result
@@ -531,13 +531,13 @@ pure fn split_str_nonempty(s: str/&a, sep: str/&b) -> [str] {
 #[doc = "
 Splits a string into a vector of the substrings separated by LF ('\\n')
 "]
-pure fn lines(s: str/&) -> [str] { split_char(s, '\n') }
+pure fn lines(s: str/&) -> [str]/~ { split_char(s, '\n') }
 
 #[doc = "
 Splits a string into a vector of the substrings separated by LF ('\\n')
 and/or CR LF ('\\r\\n')
 "]
-pure fn lines_any(s: str/&) -> [str] {
+pure fn lines_any(s: str/&) -> [str]/~ {
     vec::map(lines(s), {|s|
         let l = len(s);
         let mut cp = s;
@@ -551,7 +551,7 @@ pure fn lines_any(s: str/&) -> [str] {
 #[doc = "
 Splits a string into a vector of the substrings separated by whitespace
 "]
-pure fn words(s: str/&) -> [str] {
+pure fn words(s: str/&) -> [str]/~ {
     split_nonempty(s, {|c| char::is_whitespace(c)})
 }
 
@@ -1264,8 +1264,8 @@ pure fn is_utf16(v: [const u16]/&) -> bool {
 }
 
 #[doc = "Converts to a vector of `u16` encoded as UTF-16"]
-pure fn to_utf16(s: str/&) -> [u16] {
-    let mut u = [];
+pure fn to_utf16(s: str/&) -> [u16]/~ {
+    let mut u = []/~;
     chars_iter(s) {|cch|
         // Arithmetic with u32 literals is easier on the eyes than chars.
         let mut ch = cch as u32;
@@ -1273,14 +1273,14 @@ pure fn to_utf16(s: str/&) -> [u16] {
         if (ch & 0xFFFF_u32) == ch {
             // The BMP falls through (assuming non-surrogate, as it should)
             assert ch <= 0xD7FF_u32 || ch >= 0xE000_u32;
-            u += [ch as u16]
+            u += [ch as u16]/~
         } else {
             // Supplementary planes break into surrogates.
             assert ch >= 0x1_0000_u32 && ch <= 0x10_FFFF_u32;
             ch -= 0x1_0000_u32;
             let w1 = 0xD800_u16 | ((ch >> 10) as u16);
             let w2 = 0xDC00_u16 | ((ch as u16) & 0x3FF_u16);
-            u += [w1, w2]
+            u += [w1, w2]/~
         }
     }
     ret u;
@@ -1568,9 +1568,9 @@ interop.
 let i = str::as_bytes(\"Hello World\") { |bytes| vec::len(bytes) };
 ~~~
 "]
-pure fn as_bytes<T>(s: str, f: fn([u8]) -> T) -> T {
+pure fn as_bytes<T>(s: str, f: fn([u8]/~) -> T) -> T {
     unsafe {
-        let v: *[u8] = ::unsafe::reinterpret_cast(ptr::addr_of(s));
+        let v: *[u8]/~ = ::unsafe::reinterpret_cast(ptr::addr_of(s));
         f(*v)
     }
 }
@@ -1723,7 +1723,7 @@ mod unsafe {
 
     #[doc = "Create a Rust string from a *u8 buffer of the given length"]
     unsafe fn from_buf_len(buf: *u8, len: uint) -> str {
-        let mut v: [u8] = [];
+        let mut v: [u8]/~ = []/~;
         vec::reserve(v, len + 1u);
         vec::as_buf(v) {|b| ptr::memcpy(b, buf, len); }
         vec::unsafe::set_len(v, len);
@@ -1750,9 +1750,9 @@ mod unsafe {
 
    Does not verify that the vector contains valid UTF-8.
    "]
-   unsafe fn from_bytes(v: [const u8]) -> str {
+   unsafe fn from_bytes(v: [const u8]/~) -> str {
        unsafe {
-           let mut vcopy : [u8] = ::unsafe::transmute(copy v);
+           let mut vcopy = ::unsafe::transmute(copy v);
            vec::push(vcopy, 0u8);
            ::unsafe::transmute(vcopy)
        }
@@ -1763,7 +1763,7 @@ mod unsafe {
 
    Does not verify that the byte is valid UTF-8.
    "]
-   unsafe fn from_byte(u: u8) -> str { unsafe::from_bytes([u]) }
+   unsafe fn from_byte(u: u8) -> str { unsafe::from_bytes([u]/~) }
 
    #[doc = "
    Takes a bytewise (not UTF-8) slice from a string.
@@ -1780,7 +1780,7 @@ mod unsafe {
            assert (begin <= end);
            assert (end <= n);
 
-           let mut v = [];
+           let mut v = []/~;
            vec::reserve(v, end - begin + 1u);
            unsafe {
                vec::as_buf(v) { |vbuf|
@@ -1788,7 +1788,7 @@ mod unsafe {
                    ptr::memcpy(vbuf, src, end - begin);
                }
                vec::unsafe::set_len(v, end - begin);
-               v += [0u8];
+               v += [0u8]/~;
                ::unsafe::transmute(v)
            }
        }
@@ -1800,7 +1800,7 @@ mod unsafe {
    }
 
    #[doc = "Appends a vector of bytes to a string. (Not UTF-8 safe)."]
-   unsafe fn push_bytes(&s: str, bytes: [u8]) {
+   unsafe fn push_bytes(&s: str, bytes: [u8]/~) {
        for vec::each(bytes) {|byte| rustrt::rust_str_push(s, byte); }
    }
 
@@ -1839,7 +1839,7 @@ mod unsafe {
     #[test]
     fn test_from_buf_len() {
         unsafe {
-            let a = [65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 0u8];
+            let a = [65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 0u8]/~;
             let b = vec::unsafe::to_ptr(a);
             let c = from_buf_len(b, 3u);
             assert (c == "AAA");
@@ -1920,18 +1920,18 @@ impl extensions/& for str/& {
     fn slice(begin: uint, end: uint) -> str { slice(self, begin, end) }
     #[doc = "Splits a string into substrings using a character function"]
     #[inline]
-    fn split(sepfn: fn(char) -> bool) -> [str] { split(self, sepfn) }
+    fn split(sepfn: fn(char) -> bool) -> [str]/~ { split(self, sepfn) }
     #[doc = "
     Splits a string into substrings at each occurrence of a given character
     "]
     #[inline]
-    fn split_char(sep: char) -> [str] { split_char(self, sep) }
+    fn split_char(sep: char) -> [str]/~ { split_char(self, sep) }
     #[doc = "
     Splits a string into a vector of the substrings separated by a given
     string
     "]
     #[inline]
-    fn split_str(sep: str/&a) -> [str] { split_str(self, sep) }
+    fn split_str(sep: str/&a) -> [str]/~ { split_str(self, sep) }
     #[doc = "Returns true if one string starts with another"]
     #[inline]
     fn starts_with(needle: str/&a) -> bool { starts_with(self, needle) }
@@ -2032,79 +2032,79 @@ mod tests {
 
     #[test]
     fn test_split_char() {
-        fn t(s: str, c: char, u: [str]) {
+        fn t(s: str, c: char, u: [str]/~) {
             log(debug, "split_byte: " + s);
             let v = split_char(s, c);
             #debug("split_byte to: %?", v);
             assert vec::all2(v, u, { |a,b| a == b });
         }
-        t("abc.hello.there", '.', ["abc", "hello", "there"]);
-        t(".hello.there", '.', ["", "hello", "there"]);
-        t("...hello.there.", '.', ["", "", "", "hello", "there", ""]);
+        t("abc.hello.there", '.', ["abc", "hello", "there"]/~);
+        t(".hello.there", '.', ["", "hello", "there"]/~);
+        t("...hello.there.", '.', ["", "", "", "hello", "there", ""]/~);
 
-        assert ["", "", "", "hello", "there", ""]
+        assert ["", "", "", "hello", "there", ""]/~
             == split_char("...hello.there.", '.');
 
-        assert [""] == split_char("", 'z');
-        assert ["",""] == split_char("z", 'z');
-        assert ["ok"] == split_char("ok", 'z');
+        assert [""]/~ == split_char("", 'z');
+        assert ["",""]/~ == split_char("z", 'z');
+        assert ["ok"]/~ == split_char("ok", 'z');
     }
 
     #[test]
     fn test_split_char_2() {
         let data = "ประเทศไทย中华Việt Nam";
-        assert ["ประเทศไทย中华", "iệt Nam"]
+        assert ["ประเทศไทย中华", "iệt Nam"]/~
             == split_char(data, 'V');
-        assert ["ประเ", "ศไ", "ย中华Việt Nam"]
+        assert ["ประเ", "ศไ", "ย中华Việt Nam"]/~
             == split_char(data, 'ท');
     }
 
     #[test]
     fn test_splitn_char() {
-        fn t(s: str, c: char, n: uint, u: [str]) {
+        fn t(s: str, c: char, n: uint, u: [str]/~) {
             log(debug, "splitn_byte: " + s);
             let v = splitn_char(s, c, n);
             #debug("split_byte to: %?", v);
             #debug("comparing vs. %?", u);
             assert vec::all2(v, u, { |a,b| a == b });
         }
-        t("abc.hello.there", '.', 0u, ["abc.hello.there"]);
-        t("abc.hello.there", '.', 1u, ["abc", "hello.there"]);
-        t("abc.hello.there", '.', 2u, ["abc", "hello", "there"]);
-        t("abc.hello.there", '.', 3u, ["abc", "hello", "there"]);
-        t(".hello.there", '.', 0u, [".hello.there"]);
-        t(".hello.there", '.', 1u, ["", "hello.there"]);
-        t("...hello.there.", '.', 3u, ["", "", "", "hello.there."]);
-        t("...hello.there.", '.', 5u, ["", "", "", "hello", "there", ""]);
+        t("abc.hello.there", '.', 0u, ["abc.hello.there"]/~);
+        t("abc.hello.there", '.', 1u, ["abc", "hello.there"]/~);
+        t("abc.hello.there", '.', 2u, ["abc", "hello", "there"]/~);
+        t("abc.hello.there", '.', 3u, ["abc", "hello", "there"]/~);
+        t(".hello.there", '.', 0u, [".hello.there"]/~);
+        t(".hello.there", '.', 1u, ["", "hello.there"]/~);
+        t("...hello.there.", '.', 3u, ["", "", "", "hello.there."]/~);
+        t("...hello.there.", '.', 5u, ["", "", "", "hello", "there", ""]/~);
 
-        assert [""] == splitn_char("", 'z', 5u);
-        assert ["",""] == splitn_char("z", 'z', 5u);
-        assert ["ok"] == splitn_char("ok", 'z', 5u);
-        assert ["z"] == splitn_char("z", 'z', 0u);
-        assert ["w.x.y"] == splitn_char("w.x.y", '.', 0u);
-        assert ["w","x.y"] == splitn_char("w.x.y", '.', 1u);
+        assert [""]/~ == splitn_char("", 'z', 5u);
+        assert ["",""]/~ == splitn_char("z", 'z', 5u);
+        assert ["ok"]/~ == splitn_char("ok", 'z', 5u);
+        assert ["z"]/~ == splitn_char("z", 'z', 0u);
+        assert ["w.x.y"]/~ == splitn_char("w.x.y", '.', 0u);
+        assert ["w","x.y"]/~ == splitn_char("w.x.y", '.', 1u);
     }
 
     #[test]
     fn test_splitn_char_2 () {
         let data = "ประเทศไทย中华Việt Nam";
-        assert ["ประเทศไทย中", "Việt Nam"]
+        assert ["ประเทศไทย中", "Việt Nam"]/~
             == splitn_char(data, '华', 1u);
 
-        assert ["", "", "XXX", "YYYzWWWz"]
+        assert ["", "", "XXX", "YYYzWWWz"]/~
             == splitn_char("zzXXXzYYYzWWWz", 'z', 3u);
-        assert ["",""] == splitn_char("z", 'z', 5u);
-        assert [""] == splitn_char("", 'z', 5u);
-        assert ["ok"] == splitn_char("ok", 'z', 5u);
+        assert ["",""]/~ == splitn_char("z", 'z', 5u);
+        assert [""]/~ == splitn_char("", 'z', 5u);
+        assert ["ok"]/~ == splitn_char("ok", 'z', 5u);
     }
 
 
     #[test]
     fn test_splitn_char_3() {
         let data = "ประเทศไทย中华Việt Nam";
-        assert ["ประเทศไทย中华", "iệt Nam"]
+        assert ["ประเทศไทย中华", "iệt Nam"]/~
             == splitn_char(data, 'V', 1u);
-        assert ["ประเ", "ศไทย中华Việt Nam"]
+        assert ["ประเ", "ศไทย中华Việt Nam"]/~
             == splitn_char(data, 'ท', 1u);
 
     }
@@ -2125,40 +2125,40 @@ mod tests {
         t("::hello::there::", "::", 3, "");
 
         let data = "ประเทศไทย中华Việt Nam";
-        assert ["ประเทศไทย", "Việt Nam"]
+        assert ["ประเทศไทย", "Việt Nam"]/~
             == split_str (data, "中华");
 
-        assert ["", "XXX", "YYY", ""]
+        assert ["", "XXX", "YYY", ""]/~
             == split_str("zzXXXzzYYYzz", "zz");
 
-        assert ["zz", "zYYYz"]
+        assert ["zz", "zYYYz"]/~
             == split_str("zzXXXzYYYz", "XXX");
 
 
-        assert ["", "XXX", "YYY", ""] == split_str(".XXX.YYY.", ".");
-        assert [""] == split_str("", ".");
-        assert ["",""] == split_str("zz", "zz");
-        assert ["ok"] == split_str("ok", "z");
-        assert ["","z"] == split_str("zzz", "zz");
-        assert ["","","z"] == split_str("zzzzz", "zz");
+        assert ["", "XXX", "YYY", ""]/~ == split_str(".XXX.YYY.", ".");
+        assert [""]/~ == split_str("", ".");
+        assert ["",""]/~ == split_str("zz", "zz");
+        assert ["ok"]/~ == split_str("ok", "z");
+        assert ["","z"]/~ == split_str("zzz", "zz");
+        assert ["","","z"]/~ == split_str("zzzzz", "zz");
     }
 
 
     #[test]
     fn test_split() {
         let data = "ประเทศไทย中华Việt Nam";
-        assert ["ประเทศไทย中", "Việt Nam"]
+        assert ["ประเทศไทย中", "Việt Nam"]/~
             == split (data, {|cc| cc == '华'});
 
-        assert ["", "", "XXX", "YYY", ""]
+        assert ["", "", "XXX", "YYY", ""]/~
             == split("zzXXXzYYYz", char::is_lowercase);
 
-        assert ["zz", "", "", "z", "", "", "z"]
+        assert ["zz", "", "", "z", "", "", "z"]/~
             == split("zzXXXzYYYz", char::is_uppercase);
 
-        assert ["",""] == split("z", {|cc| cc == 'z'});
-        assert [""] == split("", {|cc| cc == 'z'});
-        assert ["ok"] == split("ok", {|cc| cc == 'z'});
+        assert ["",""]/~ == split("z", {|cc| cc == 'z'});
+        assert [""]/~ == split("", {|cc| cc == 'z'});
+        assert ["ok"]/~ == split("ok", {|cc| cc == 'z'});
     }
 
     #[test]
@@ -2166,34 +2166,34 @@ mod tests {
         let lf = "\nMary had a little lamb\nLittle lamb\n";
         let crlf = "\r\nMary had a little lamb\r\nLittle lamb\r\n";
 
-        assert ["", "Mary had a little lamb", "Little lamb", ""]
+        assert ["", "Mary had a little lamb", "Little lamb", ""]/~
             == lines(lf);
 
-        assert ["", "Mary had a little lamb", "Little lamb", ""]
+        assert ["", "Mary had a little lamb", "Little lamb", ""]/~
             == lines_any(lf);
 
-        assert ["\r", "Mary had a little lamb\r", "Little lamb\r", ""]
+        assert ["\r", "Mary had a little lamb\r", "Little lamb\r", ""]/~
             == lines(crlf);
 
-        assert ["", "Mary had a little lamb", "Little lamb", ""]
+        assert ["", "Mary had a little lamb", "Little lamb", ""]/~
             == lines_any(crlf);
 
-        assert [""] == lines    ("");
-        assert [""] == lines_any("");
-        assert ["",""] == lines    ("\n");
-        assert ["",""] == lines_any("\n");
-        assert ["banana"] == lines    ("banana");
-        assert ["banana"] == lines_any("banana");
+        assert [""]/~ == lines    ("");
+        assert [""]/~ == lines_any("");
+        assert ["",""]/~ == lines    ("\n");
+        assert ["",""]/~ == lines_any("\n");
+        assert ["banana"]/~ == lines    ("banana");
+        assert ["banana"]/~ == lines_any("banana");
     }
 
     #[test]
     fn test_words () {
         let data = "\nMary had a little lamb\nLittle lamb\n";
-        assert ["Mary","had","a","little","lamb","Little","lamb"]
+        assert ["Mary","had","a","little","lamb","Little","lamb"]/~
             == words(data);
 
-        assert ["ok"] == words("ok");
-        assert [] == words("");
+        assert ["ok"]/~ == words("ok");
+        assert []/~ == words("");
     }
 
     #[test]
@@ -2250,22 +2250,23 @@ mod tests {
 
     #[test]
     fn test_concat() {
-        fn t(v: [str], s: str) { assert (eq(concat(v), s)); }
-        t(["you", "know", "I'm", "no", "good"], "youknowI'mnogood");
-        let v: [str] = [];
+        fn t(v: [str]/~, s: str) { assert (eq(concat(v), s)); }
+        t(["you", "know", "I'm", "no", "good"]/~, "youknowI'mnogood");
+        let v: [str]/~ = []/~;
         t(v, "");
-        t(["hi"], "hi");
+        t(["hi"]/~, "hi");
     }
 
     #[test]
     fn test_connect() {
-        fn t(v: [str], sep: str, s: str) {
+        fn t(v: [str]/~, sep: str, s: str) {
             assert (eq(connect(v, sep), s));
         }
-        t(["you", "know", "I'm", "no", "good"], " ", "you know I'm no good");
-        let v: [str] = [];
+        t(["you", "know", "I'm", "no", "good"]/~,
+          " ", "you know I'm no good");
+        let v: [str]/~ = []/~;
         t(v, " ", "");
-        t(["hi"], " ", "hi");
+        t(["hi"]/~, " ", "hi");
     }
 
     #[test]
@@ -2517,7 +2518,7 @@ mod tests {
 
     #[test]
     fn test_unsafe_from_bytes() {
-        let a = [65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 65u8];
+        let a = [65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 65u8]/~;
         let b = unsafe { unsafe::from_bytes(a) };
         assert (b == "AAAAAAA");
     }
@@ -2534,7 +2535,7 @@ mod tests {
                   0x56_u8, 0x69_u8, 0xe1_u8,
                   0xbb_u8, 0x87_u8, 0x74_u8,
                   0x20_u8, 0x4e_u8, 0x61_u8,
-                  0x6d_u8];
+                  0x6d_u8]/~;
 
          assert ss == from_bytes(bb);
     }
@@ -2552,7 +2553,7 @@ mod tests {
                   0x56_u8, 0x69_u8, 0xe1_u8,
                   0xbb_u8, 0x87_u8, 0x74_u8,
                   0x20_u8, 0x4e_u8, 0x61_u8,
-                  0x6d_u8];
+                  0x6d_u8]/~;
 
          let _x = from_bytes(bb);
     }
@@ -2560,7 +2561,7 @@ mod tests {
     #[test]
     fn test_from_buf() {
         unsafe {
-            let a = [65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 0u8];
+            let a = [65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 0u8]/~;
             let b = vec::unsafe::to_ptr(a);
             let c = unsafe::from_buf(b);
             assert (c == "AAAAAAA");
@@ -2609,7 +2610,7 @@ mod tests {
     fn vec_str_conversions() {
         let s1: str = "All mimsy were the borogoves";
 
-        let v: [u8] = bytes(s1);
+        let v: [u8]/~ = bytes(s1);
         let s2: str = from_bytes(v);
         let mut i: uint = 0u;
         let n1: uint = len(s1);
@@ -2774,7 +2775,7 @@ mod tests {
     #[test]
     fn test_chars() {
         let ss = "ศไทย中华Việt Nam";
-        assert ['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m']
+        assert ['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m']/~
             == chars(ss);
     }
 
@@ -2785,7 +2786,7 @@ mod tests {
               [0xd800_u16, 0xdf45_u16, 0xd800_u16, 0xdf3f_u16,
                0xd800_u16, 0xdf3b_u16, 0xd800_u16, 0xdf46_u16,
                0xd800_u16, 0xdf39_u16, 0xd800_u16, 0xdf3b_u16,
-               0xd800_u16, 0xdf30_u16, 0x000a_u16]),
+               0xd800_u16, 0xdf30_u16, 0x000a_u16]/~),
 
              ("𐐒𐑉𐐮𐑀𐐲𐑋 𐐏𐐲𐑍\n",
               [0xd801_u16, 0xdc12_u16, 0xd801_u16,
@@ -2793,7 +2794,7 @@ mod tests {
                0xdc40_u16, 0xd801_u16, 0xdc32_u16, 0xd801_u16,
                0xdc4b_u16, 0x0020_u16, 0xd801_u16, 0xdc0f_u16,
                0xd801_u16, 0xdc32_u16, 0xd801_u16, 0xdc4d_u16,
-               0x000a_u16]),
+               0x000a_u16]/~),
 
              ("𐌀𐌖𐌋𐌄𐌑𐌉·𐌌𐌄𐌕𐌄𐌋𐌉𐌑\n",
               [0xd800_u16, 0xdf00_u16, 0xd800_u16, 0xdf16_u16,
@@ -2802,7 +2803,7 @@ mod tests {
                0x00b7_u16, 0xd800_u16, 0xdf0c_u16, 0xd800_u16,
                0xdf04_u16, 0xd800_u16, 0xdf15_u16, 0xd800_u16,
                0xdf04_u16, 0xd800_u16, 0xdf0b_u16, 0xd800_u16,
-               0xdf09_u16, 0xd800_u16, 0xdf11_u16, 0x000a_u16 ]),
+               0xdf09_u16, 0xd800_u16, 0xdf11_u16, 0x000a_u16 ]/~),
 
              ("𐒋𐒘𐒈𐒑𐒛𐒒 𐒕𐒓 𐒈𐒚𐒍 𐒏𐒜𐒒𐒖𐒆 𐒕𐒆\n",
               [0xd801_u16, 0xdc8b_u16, 0xd801_u16, 0xdc98_u16,
@@ -2815,7 +2816,7 @@ mod tests {
                0xdc9c_u16, 0xd801_u16, 0xdc92_u16, 0xd801_u16,
                0xdc96_u16, 0xd801_u16, 0xdc86_u16, 0x0020_u16,
                0xd801_u16, 0xdc95_u16, 0xd801_u16, 0xdc86_u16,
-               0x000a_u16 ]) ];
+               0x000a_u16 ]/~) ]/~;
 
         for vec::each(pairs) {|p|
             let (s, u) = p;