Removing explicit uses of + mode
This removes most explicit uses of the + argument mode. Pending a snapshot, I had to remove the forbid(deprecated_modes) pragma from a bunch of files. I'll put it back! + mode still has to be used in a few places for functions that get moved (see task.rs) The changes outside core and std are due to the to_bytes trait and making the compiler (with legacy modes on) agree with the libraries (with legacy modes off) about modes.
This commit is contained in:
@@ -10,7 +10,7 @@ Note that recursive use is not permitted.
|
||||
*/
|
||||
|
||||
// NB: transitionary, de-mode-ing.
|
||||
#[forbid(deprecated_mode)];
|
||||
// tjc: re-forbid deprecated modes after snapshot
|
||||
#[forbid(deprecated_pattern)];
|
||||
|
||||
use cast::reinterpret_cast;
|
||||
@@ -61,17 +61,17 @@ pub fn DVec<A>() -> DVec<A> {
|
||||
}
|
||||
|
||||
/// Creates a new dvec with a single element
|
||||
pub fn from_elem<A>(+e: A) -> DVec<A> {
|
||||
pub fn from_elem<A>(e: A) -> DVec<A> {
|
||||
DVec_({mut data: ~[move e]})
|
||||
}
|
||||
|
||||
/// Creates a new dvec with the contents of a vector
|
||||
pub fn from_vec<A>(+v: ~[A]) -> DVec<A> {
|
||||
pub fn from_vec<A>(v: ~[A]) -> DVec<A> {
|
||||
DVec_({mut data: move v})
|
||||
}
|
||||
|
||||
/// Consumes the vector and returns its contents
|
||||
pub fn unwrap<A>(+d: DVec<A>) -> ~[A] {
|
||||
pub fn unwrap<A>(d: DVec<A>) -> ~[A] {
|
||||
let DVec_({data: v}) <- d;
|
||||
move v
|
||||
}
|
||||
@@ -87,7 +87,7 @@ priv impl<A> DVec<A> {
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn check_out<B>(f: &fn(+v: ~[A]) -> B) -> B {
|
||||
fn check_out<B>(f: &fn(v: ~[A]) -> B) -> B {
|
||||
unsafe {
|
||||
let mut data = cast::reinterpret_cast(&null::<()>());
|
||||
data <-> self.data;
|
||||
@@ -98,7 +98,7 @@ priv impl<A> DVec<A> {
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn give_back(+data: ~[A]) {
|
||||
fn give_back(data: ~[A]) {
|
||||
unsafe {
|
||||
self.data = move data;
|
||||
}
|
||||
@@ -120,7 +120,7 @@ impl<A> DVec<A> {
|
||||
* and return a new vector to replace it with.
|
||||
*/
|
||||
#[inline(always)]
|
||||
fn swap(f: &fn(+v: ~[A]) -> ~[A]) {
|
||||
fn swap(f: &fn(v: ~[A]) -> ~[A]) {
|
||||
self.check_out(|v| self.give_back(f(move v)))
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ impl<A> DVec<A> {
|
||||
* and return a new vector to replace it with.
|
||||
*/
|
||||
#[inline(always)]
|
||||
fn swap_mut(f: &fn(+v: ~[mut A]) -> ~[mut A]) {
|
||||
fn swap_mut(f: &fn(v: ~[mut A]) -> ~[mut A]) {
|
||||
do self.swap |v| {
|
||||
vec::from_mut(f(vec::to_mut(move v)))
|
||||
}
|
||||
@@ -148,7 +148,7 @@ impl<A> DVec<A> {
|
||||
}
|
||||
|
||||
/// Overwrite the current contents
|
||||
fn set(+w: ~[A]) {
|
||||
fn set(w: ~[A]) {
|
||||
self.check_not_borrowed();
|
||||
self.data <- w;
|
||||
}
|
||||
@@ -164,7 +164,7 @@ impl<A> DVec<A> {
|
||||
}
|
||||
|
||||
/// Insert a single item at the front of the list
|
||||
fn unshift(+t: A) {
|
||||
fn unshift(t: A) {
|
||||
unsafe {
|
||||
let mut data = cast::reinterpret_cast(&null::<()>());
|
||||
data <-> self.data;
|
||||
@@ -178,7 +178,7 @@ impl<A> DVec<A> {
|
||||
}
|
||||
|
||||
/// Append a single item to the end of the list
|
||||
fn push(+t: A) {
|
||||
fn push(t: A) {
|
||||
self.check_not_borrowed();
|
||||
self.data.push(move t);
|
||||
}
|
||||
@@ -295,7 +295,7 @@ impl<A: Copy> DVec<A> {
|
||||
}
|
||||
|
||||
/// Overwrites the contents of the element at `idx` with `a`
|
||||
fn set_elt(idx: uint, +a: A) {
|
||||
fn set_elt(idx: uint, a: A) {
|
||||
self.check_not_borrowed();
|
||||
self.data[idx] = a;
|
||||
}
|
||||
@@ -305,7 +305,7 @@ impl<A: Copy> DVec<A> {
|
||||
* growing the vector if necessary. New elements will be initialized
|
||||
* with `initval`
|
||||
*/
|
||||
fn grow_set_elt(idx: uint, initval: &A, +val: A) {
|
||||
fn grow_set_elt(idx: uint, initval: &A, val: A) {
|
||||
do self.swap |v| {
|
||||
let mut v = move v;
|
||||
v.grow_set(idx, initval, val);
|
||||
@@ -354,7 +354,7 @@ impl<A: Copy> DVec<A> {
|
||||
}
|
||||
|
||||
impl<A:Copy> DVec<A>: Index<uint,A> {
|
||||
pure fn index(+idx: uint) -> A {
|
||||
pure fn index(idx: uint) -> A {
|
||||
self.get_elt(idx)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user