From f010f79a6164beab6a3cf920d325b2fb854e1b49 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sat, 16 Jul 2011 16:59:17 -0700 Subject: [PATCH] Add std::ivec::to_mut, from_mut --- src/lib/ivec.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/lib/ivec.rs b/src/lib/ivec.rs index 677fddc35c5a..31754df8bbda 100644 --- a/src/lib/ivec.rs +++ b/src/lib/ivec.rs @@ -72,6 +72,22 @@ fn init_elt_mut[T](&T t, uint n_elts) -> T[mutable] { ret v; } +fn to_mut[T](&T[] v) -> T[mutable] { + auto vres = ~[mutable]; + for (T t in v) { + vres += ~[mutable t]; + } + ret vres; +} + +fn from_mut[T](&T[mutable] v) -> T[] { + auto vres = ~[]; + for (T t in v) { + vres += ~[t]; + } + ret vres; +} + // Predicates pred is_empty[T](&T[mutable?] v) -> bool { // FIXME: This would be easier if we could just call len