summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2012-06-02 19:03:28 -0700
committerNiko Matsakis <niko@alum.mit.edu>2012-06-02 19:14:57 -0700
commit3f6e6532ac17e97ce48b91e07340361a32ef480b (patch)
tree8aba1f764b51f07fad2f41a67adbdae980023eb4 /src/libstd
parente94683dce9832dddf5af5c5ffd1384c7fd113729 (diff)
downloadrust-3f6e6532ac17e97ce48b91e07340361a32ef480b.tar.gz
rust-3f6e6532ac17e97ce48b91e07340361a32ef480b.zip
make vec fns/methods take imm slices.
this also repairs the unsoundness in typing of unpack_slice,
which was silently converting a const ptr to an imm one.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/list.rs15
-rw-r--r--src/libstd/par.rs14
2 files changed, 8 insertions, 21 deletions
diff --git a/src/libstd/list.rs b/src/libstd/list.rs
index cc582d370bf..5a468df4c88 100644
--- a/src/libstd/list.rs
+++ b/src/libstd/list.rs
@@ -10,7 +10,7 @@ enum list<T> {
 }
 
 #[doc = "Create a list from a vector"]
-fn from_vec<T: copy>(v: [const T]) -> @list<T> {
+fn from_vec<T: copy>(v: [T]) -> @list<T> {
     vec::foldr(v, @nil::<T>, { |h, t| @cons(h, t) })
 }
 
@@ -168,19 +168,6 @@ mod tests {
     }
 
     #[test]
-    fn test_from_vec_mut() {
-        let l = from_vec([mut 0, 1, 2]);
-
-        assert (head(l) == 0);
-
-        let tail_l = tail(l);
-        assert (head(tail_l) == 1);
-
-        let tail_tail_l = tail(tail_l);
-        assert (head(tail_tail_l) == 2);
-    }
-
-    #[test]
     fn test_foldl() {
         fn add(&&a: uint, &&b: int) -> uint { ret a + (b as uint); }
         let l = from_vec([0, 1, 2, 3, 4]);
diff --git a/src/libstd/par.rs b/src/libstd/par.rs
index 5db344713a7..d12a7e71a63 100644
--- a/src/libstd/par.rs
+++ b/src/libstd/par.rs
@@ -20,7 +20,7 @@ This is used to build most of the other parallel vector functions,
 like map or alli."]
 fn map_slices<A: copy send, B: copy send>(
     xs: [A],
-    f: fn() -> fn~(uint, [const A]/&) -> B)
+    f: fn() -> fn~(uint, [A]/&) -> B)
     -> [B] {
 
     let len = xs.len();
@@ -48,7 +48,7 @@ fn map_slices<A: copy send, B: copy send>(
                         let slice = (ptr::offset(p, base),
                                      len * sys::size_of::<A>());
                         log(info, #fmt("pre-slice: %?", (base, slice)));
-                        let slice : [const A]/& =
+                        let slice : [A]/& =
                             unsafe::reinterpret_cast(slice);
                         log(info, #fmt("slice: %?",
                                        (base, vec::len(slice), end - base)));
@@ -75,7 +75,7 @@ fn map_slices<A: copy send, B: copy send>(
 #[doc="A parallel version of map."]
 fn map<A: copy send, B: copy send>(xs: [A], f: fn~(A) -> B) -> [B] {
     vec::concat(map_slices(xs) {||
-        fn~(_base: uint, slice : [const A]/&, copy f) -> [B] {
+        fn~(_base: uint, slice : [A]/&, copy f) -> [B] {
             vec::map(slice, f)
         }
     })
@@ -84,7 +84,7 @@ fn map<A: copy send, B: copy send>(xs: [A], f: fn~(A) -> B) -> [B] {
 #[doc="A parallel version of mapi."]
 fn mapi<A: copy send, B: copy send>(xs: [A], f: fn~(uint, A) -> B) -> [B] {
     let slices = map_slices(xs) {||
-        fn~(base: uint, slice : [const A]/&, copy f) -> [B] {
+        fn~(base: uint, slice : [A]/&, copy f) -> [B] {
             vec::mapi(slice) {|i, x|
                 f(i + base, x)
             }
@@ -104,7 +104,7 @@ fn mapi_factory<A: copy send, B: copy send>(
     xs: [A], f: fn() -> fn~(uint, A) -> B) -> [B] {
     let slices = map_slices(xs) {||
         let f = f();
-        fn~(base: uint, slice : [const A]/&, move f) -> [B] {
+        fn~(base: uint, slice : [A]/&, move f) -> [B] {
             vec::mapi(slice) {|i, x|
                 f(i + base, x)
             }
@@ -119,7 +119,7 @@ fn mapi_factory<A: copy send, B: copy send>(
 #[doc="Returns true if the function holds for all elements in the vector."]
 fn alli<A: copy send>(xs: [A], f: fn~(uint, A) -> bool) -> bool {
     vec::all(map_slices(xs) {||
-        fn~(base: uint, slice : [const A]/&, copy f) -> bool {
+        fn~(base: uint, slice : [A]/&, copy f) -> bool {
             vec::alli(slice) {|i, x|
                 f(i + base, x)
             }
@@ -130,7 +130,7 @@ fn alli<A: copy send>(xs: [A], f: fn~(uint, A) -> bool) -> bool {
 #[doc="Returns true if the function holds for any elements in the vector."]
 fn any<A: copy send>(xs: [A], f: fn~(A) -> bool) -> bool {
     vec::any(map_slices(xs) {||
-        fn~(_base : uint, slice: [const A]/&, copy f) -> bool {
+        fn~(_base : uint, slice: [A]/&, copy f) -> bool {
             vec::any(slice, f)
         }
     }) {|x| x }