Remove uses of + mode from libstd

More or less the same as my analogous commit for libcore. Had
to remove the forbid(deprecated_modes) pragma from some files -- will
restore it after the snapshot.
This commit is contained in:
Tim Chevalier 2012-10-03 12:21:48 -07:00
parent 654b4d6987
commit f33539e446
21 changed files with 113 additions and 115 deletions

View File

@ -1,5 +1,5 @@
// NB: transitionary, de-mode-ing.
#[forbid(deprecated_mode)];
// tjc: forbid deprecated modes again after snap
/**
* Concurrency-enabled mechanisms for sharing mutable and/or immutable state
* between tasks.
@ -66,7 +66,7 @@ impl &Condvar {
struct ARC<T: Const Send> { x: SharedMutableState<T> }
/// Create an atomically reference counted wrapper.
pub fn ARC<T: Const Send>(+data: T) -> ARC<T> {
pub fn ARC<T: Const Send>(data: T) -> ARC<T> {
ARC { x: unsafe { shared_mutable_state(move data) } }
}
@ -98,7 +98,7 @@ pub fn clone<T: Const Send>(rc: &ARC<T>) -> ARC<T> {
* unwrap from a task that holds another reference to the same ARC; it is
* guaranteed to deadlock.
*/
fn unwrap<T: Const Send>(+rc: ARC<T>) -> T {
fn unwrap<T: Const Send>(rc: ARC<T>) -> T {
let ARC { x: x } <- rc;
unsafe { unwrap_shared_mutable_state(move x) }
}
@ -113,14 +113,14 @@ struct MutexARCInner<T: Send> { lock: Mutex, failed: bool, data: T }
struct MutexARC<T: Send> { x: SharedMutableState<MutexARCInner<T>> }
/// Create a mutex-protected ARC with the supplied data.
pub fn MutexARC<T: Send>(+user_data: T) -> MutexARC<T> {
pub fn MutexARC<T: Send>(user_data: T) -> MutexARC<T> {
mutex_arc_with_condvars(move user_data, 1)
}
/**
* Create a mutex-protected ARC with the supplied data and a specified number
* of condvars (as sync::mutex_with_condvars).
*/
pub fn mutex_arc_with_condvars<T: Send>(+user_data: T,
pub fn mutex_arc_with_condvars<T: Send>(user_data: T,
num_condvars: uint) -> MutexARC<T> {
let data =
MutexARCInner { lock: mutex_with_condvars(num_condvars),
@ -191,7 +191,7 @@ impl<T: Send> &MutexARC<T> {
* Will additionally fail if another task has failed while accessing the arc.
*/
// FIXME(#2585) make this a by-move method on the arc
pub fn unwrap_mutex_arc<T: Send>(+arc: MutexARC<T>) -> T {
pub fn unwrap_mutex_arc<T: Send>(arc: MutexARC<T>) -> T {
let MutexARC { x: x } <- arc;
let inner = unsafe { unwrap_shared_mutable_state(move x) };
let MutexARCInner { failed: failed, data: data, _ } <- inner;
@ -247,14 +247,14 @@ struct RWARC<T: Const Send> {
}
/// Create a reader/writer ARC with the supplied data.
pub fn RWARC<T: Const Send>(+user_data: T) -> RWARC<T> {
pub fn RWARC<T: Const Send>(user_data: T) -> RWARC<T> {
rw_arc_with_condvars(move user_data, 1)
}
/**
* Create a reader/writer ARC with the supplied data and a specified number
* of condvars (as sync::rwlock_with_condvars).
*/
pub fn rw_arc_with_condvars<T: Const Send>(+user_data: T,
pub fn rw_arc_with_condvars<T: Const Send>(user_data: T,
num_condvars: uint) -> RWARC<T> {
let data =
RWARCInner { lock: rwlock_with_condvars(num_condvars),
@ -334,7 +334,7 @@ impl<T: Const Send> &RWARC<T> {
* }
* ~~~
*/
fn write_downgrade<U>(blk: fn(+v: RWWriteMode<T>) -> U) -> U {
fn write_downgrade<U>(blk: fn(v: RWWriteMode<T>) -> U) -> U {
let state = unsafe { get_shared_mutable_state(&self.x) };
do borrow_rwlock(state).write_downgrade |write_mode| {
check_poison(false, state.failed);
@ -344,7 +344,7 @@ impl<T: Const Send> &RWARC<T> {
}
/// To be called inside of the write_downgrade block.
fn downgrade(+token: RWWriteMode/&a<T>) -> RWReadMode/&a<T> {
fn downgrade(token: RWWriteMode/&a<T>) -> RWReadMode/&a<T> {
// The rwlock should assert that the token belongs to us for us.
let state = unsafe { get_shared_immutable_state(&self.x) };
let RWWriteMode((data, t, _poison)) <- token;
@ -369,7 +369,7 @@ impl<T: Const Send> &RWARC<T> {
* in write mode.
*/
// FIXME(#2585) make this a by-move method on the arc
pub fn unwrap_rw_arc<T: Const Send>(+arc: RWARC<T>) -> T {
pub fn unwrap_rw_arc<T: Const Send>(arc: RWARC<T>) -> T {
let RWARC { x: x, _ } <- arc;
let inner = unsafe { unwrap_shared_mutable_state(move x) };
let RWARCInner { failed: failed, data: data, _ } <- inner;

View File

@ -1,4 +1,4 @@
#[forbid(deprecated_mode)];
// tjc: forbid deprecated modes again after snap
use vec::{to_mut, from_elem};
@ -95,7 +95,7 @@ struct BigBitv {
mut storage: ~[mut uint]
}
fn BigBitv(+storage: ~[mut uint]) -> BigBitv {
fn BigBitv(storage: ~[mut uint]) -> BigBitv {
BigBitv {storage: storage}
}

View File

@ -1,4 +1,4 @@
#[forbid(deprecated_mode)];
// tjc: forbid deprecated modes again after snap
/// A dynamic, mutable location.
///
/// Similar to a mutable option type, but friendlier.
@ -8,7 +8,7 @@ pub struct Cell<T> {
}
/// Creates a new full cell with the given value.
pub fn Cell<T>(+value: T) -> Cell<T> {
pub fn Cell<T>(value: T) -> Cell<T> {
Cell { value: Some(move value) }
}
@ -29,7 +29,7 @@ impl<T> Cell<T> {
}
/// Returns the value, failing if the cell is full.
fn put_back(+value: T) {
fn put_back(value: T) {
if !self.is_empty() {
fail ~"attempt to put a value back into a full cell";
}

View File

@ -1,4 +1,4 @@
#[forbid(deprecated_mode)];
// tjc: forbid deprecated modes again after snap
//! Unsafe debugging functions for inspecting values.
use cast::reinterpret_cast;
@ -20,7 +20,7 @@ pub fn debug_tydesc<T>() {
rustrt::debug_tydesc(sys::get_type_desc::<T>());
}
pub fn debug_opaque<T>(+x: T) {
pub fn debug_opaque<T>(x: T) {
rustrt::debug_opaque(sys::get_type_desc::<T>(), ptr::addr_of(&x) as *());
}
@ -28,11 +28,11 @@ pub fn debug_box<T>(x: @T) {
rustrt::debug_box(sys::get_type_desc::<T>(), ptr::addr_of(&x) as *());
}
pub fn debug_tag<T>(+x: T) {
pub fn debug_tag<T>(x: T) {
rustrt::debug_tag(sys::get_type_desc::<T>(), ptr::addr_of(&x) as *());
}
pub fn debug_fn<T>(+x: T) {
pub fn debug_fn<T>(x: T) {
rustrt::debug_fn(sys::get_type_desc::<T>(), ptr::addr_of(&x) as *());
}

View File

@ -1,5 +1,5 @@
//! A deque. Untested as of yet. Likely buggy
#[forbid(deprecated_mode)];
// tjc: forbid deprecated modes again after snap
#[forbid(non_camel_case_types)];
use option::{Some, None};
@ -8,8 +8,8 @@ use core::cmp::{Eq};
pub trait Deque<T> {
fn size() -> uint;
fn add_front(+v: T);
fn add_back(+v: T);
fn add_front(v: T);
fn add_back(v: T);
fn pop_front() -> T;
fn pop_back() -> T;
fn peek_front() -> T;
@ -27,7 +27,7 @@ pub fn create<T: Copy>() -> Deque<T> {
* Grow is only called on full elts, so nelts is also len(elts), unlike
* elsewhere.
*/
fn grow<T: Copy>(nelts: uint, lo: uint, +elts: ~[Cell<T>])
fn grow<T: Copy>(nelts: uint, lo: uint, elts: ~[Cell<T>])
-> ~[Cell<T>] {
let mut elts = move elts;
assert (nelts == vec::len(elts));
@ -55,7 +55,7 @@ pub fn create<T: Copy>() -> Deque<T> {
impl <T: Copy> Repr<T>: Deque<T> {
fn size() -> uint { return self.nelts; }
fn add_front(+t: T) {
fn add_front(t: T) {
let oldlo: uint = self.lo;
if self.lo == 0u {
self.lo = self.elts.len() - 1u;
@ -68,7 +68,7 @@ pub fn create<T: Copy>() -> Deque<T> {
self.elts.set_elt(self.lo, Some(t));
self.nelts += 1u;
}
fn add_back(+t: T) {
fn add_back(t: T) {
if self.lo == self.hi && self.nelts != 0u {
self.elts.swap(|v| grow(self.nelts, self.lo, move v));
self.lo = 0u;
@ -200,7 +200,7 @@ mod tests {
assert (deq.get(3) == d);
}
fn test_parameterized<T: Copy Eq Owned>(+a: T, +b: T, +c: T, +d: T) {
fn test_parameterized<T: Copy Eq Owned>(a: T, +b: T, +c: T, +d: T) {
let deq: deque::Deque<T> = deque::create::<T>();
assert (deq.size() == 0u);
deq.add_front(a);

View File

@ -62,7 +62,7 @@
* }
*/
#[forbid(deprecated_mode)];
// tjc: forbid deprecated modes again after snap
use core::cmp::Eq;
use core::result::{Err, Ok};
@ -179,7 +179,7 @@ pub enum Fail_ {
}
/// Convert a `fail_` enum into an error string
pub fn fail_str(+f: Fail_) -> ~str {
pub fn fail_str(f: Fail_) -> ~str {
return match f {
ArgumentMissing(ref nm) => {
~"Argument to option '" + *nm + ~"' missing."
@ -335,7 +335,7 @@ pub fn getopts(args: &[~str], opts: &[Opt]) -> Result unsafe {
free: free});
}
fn opt_vals(+mm: Matches, nm: &str) -> ~[Optval] {
fn opt_vals(mm: Matches, nm: &str) -> ~[Optval] {
return match find_opt(mm.opts, mkname(nm)) {
Some(id) => mm.vals[id],
None => {
@ -345,15 +345,15 @@ fn opt_vals(+mm: Matches, nm: &str) -> ~[Optval] {
};
}
fn opt_val(+mm: Matches, nm: &str) -> Optval { return opt_vals(mm, nm)[0]; }
fn opt_val(mm: Matches, nm: &str) -> Optval { return opt_vals(mm, nm)[0]; }
/// Returns true if an option was matched
pub fn opt_present(+mm: Matches, nm: &str) -> bool {
pub fn opt_present(mm: Matches, nm: &str) -> bool {
return vec::len::<Optval>(opt_vals(mm, nm)) > 0u;
}
/// Returns true if any of several options were matched
pub fn opts_present(+mm: Matches, names: &[~str]) -> bool {
pub fn opts_present(mm: Matches, names: &[~str]) -> bool {
for vec::each(names) |nm| {
match find_opt(mm.opts, mkname(*nm)) {
Some(_) => return true,
@ -370,7 +370,7 @@ pub fn opts_present(+mm: Matches, names: &[~str]) -> bool {
* Fails if the option was not matched or if the match did not take an
* argument
*/
pub fn opt_str(+mm: Matches, nm: &str) -> ~str {
pub fn opt_str(mm: Matches, nm: &str) -> ~str {
return match opt_val(mm, nm) { Val(copy s) => s, _ => fail };
}
@ -380,7 +380,8 @@ pub fn opt_str(+mm: Matches, nm: &str) -> ~str {
* Fails if the no option was provided from the given list, or if the no such
* option took an argument
*/
pub fn opts_str(+mm: Matches, names: &[~str]) -> ~str {
pub fn opts_str(mm: Matches, names: &[~str]) -> ~str {
>>>>>>> Remove uses of + mode from libstd
for vec::each(names) |nm| {
match opt_val(mm, *nm) {
Val(copy s) => return s,
@ -397,7 +398,7 @@ pub fn opts_str(+mm: Matches, names: &[~str]) -> ~str {
*
* Used when an option accepts multiple values.
*/
pub fn opt_strs(+mm: Matches, nm: &str) -> ~[~str] {
pub fn opt_strs(mm: Matches, nm: &str) -> ~[~str] {
let mut acc: ~[~str] = ~[];
for vec::each(opt_vals(mm, nm)) |v| {
match *v { Val(copy s) => acc.push(s), _ => () }
@ -406,7 +407,7 @@ pub fn opt_strs(+mm: Matches, nm: &str) -> ~[~str] {
}
/// Returns the string argument supplied to a matching option or none
pub fn opt_maybe_str(+mm: Matches, nm: &str) -> Option<~str> {
pub fn opt_maybe_str(mm: Matches, nm: &str) -> Option<~str> {
let vals = opt_vals(mm, nm);
if vec::len::<Optval>(vals) == 0u { return None::<~str>; }
return match vals[0] {
@ -423,7 +424,7 @@ pub fn opt_maybe_str(+mm: Matches, nm: &str) -> Option<~str> {
* present but no argument was provided, and the argument if the option was
* present and an argument was provided.
*/
pub fn opt_default(+mm: Matches, nm: &str, def: &str) -> Option<~str> {
pub fn opt_default(mm: Matches, nm: &str, def: &str) -> Option<~str> {
let vals = opt_vals(mm, nm);
if vec::len::<Optval>(vals) == 0u { return None::<~str>; }
return match vals[0] { Val(copy s) => Some::<~str>(s),
@ -451,7 +452,7 @@ mod tests {
use opt = getopts;
use result::{Err, Ok};
fn check_fail_type(+f: Fail_, ft: FailType) {
fn check_fail_type(f: Fail_, ft: FailType) {
match f {
ArgumentMissing(_) => assert ft == ArgumentMissing_,
UnrecognizedOption(_) => assert ft == UnrecognizedOption_,

View File

@ -1,6 +1,6 @@
// Rust JSON serialization library
// Copyright (c) 2011 Google Inc.
#[forbid(deprecated_mode)];
// tjc: forbid deprecated modes again after snap
#[forbid(non_camel_case_types)];
//! json serialization
@ -370,7 +370,7 @@ priv impl Parser {
self.ch
}
fn error<T>(+msg: ~str) -> Result<T, Error> {
fn error<T>(msg: ~str) -> Result<T, Error> {
Err(Error { line: self.line, col: self.col, msg: @msg })
}

View File

@ -29,7 +29,7 @@ pub fn from_vec<T: Copy>(v: &[T]) -> @List<T> {
* * z - The initial value
* * f - The function to apply
*/
pub fn foldl<T: Copy, U>(+z: T, ls: @List<U>, f: fn((&T), (&U)) -> T) -> T {
pub fn foldl<T: Copy, U>(z: T, ls: @List<U>, f: fn((&T), (&U)) -> T) -> T {
let mut accum: T = z;
do iter(ls) |elt| { accum = f(&accum, elt);}
accum

View File

@ -1,6 +1,6 @@
//! A map type
#[forbid(deprecated_mode)];
// tjc: forbid deprecated modes again after snap
use io::WriterUtil;
use to_str::ToStr;
@ -28,10 +28,10 @@ pub trait Map<K:Eq IterBytes Hash Copy, V: Copy> {
*
* Returns true if the key did not already exist in the map
*/
fn insert(+v: K, +v: V) -> bool;
fn insert(v: K, +v: V) -> bool;
/// Returns true if the map contains a value for the specified key
fn contains_key(+key: K) -> bool;
fn contains_key(key: K) -> bool;
/// Returns true if the map contains a value for the specified
/// key, taking the key by reference.
@ -41,31 +41,31 @@ pub trait Map<K:Eq IterBytes Hash Copy, V: Copy> {
* Get the value for the specified key. Fails if the key does not exist in
* the map.
*/
fn get(+key: K) -> V;
fn get(key: K) -> V;
/**
* Get the value for the specified key. If the key does not exist in
* the map then returns none.
*/
pure fn find(+key: K) -> Option<V>;
pure fn find(key: K) -> Option<V>;
/**
* Remove and return a value from the map. Returns true if the
* key was present in the map, otherwise false.
*/
fn remove(+key: K) -> bool;
fn remove(key: K) -> bool;
/// Clear the map, removing all key/value pairs.
fn clear();
/// Iterate over all the key/value pairs in the map by value
pure fn each(fn(+key: K, +value: V) -> bool);
pure fn each(fn(key: K, +value: V) -> bool);
/// Iterate over all the keys in the map by value
pure fn each_key(fn(+key: K) -> bool);
pure fn each_key(fn(key: K) -> bool);
/// Iterate over all the values in the map by value
pure fn each_value(fn(+value: V) -> bool);
pure fn each_value(fn(value: V) -> bool);
/// Iterate over all the key/value pairs in the map by reference
pure fn each_ref(fn(key: &K, value: &V) -> bool);
@ -201,7 +201,7 @@ pub mod chained {
impl<K:Eq IterBytes Hash Copy, V: Copy> T<K, V>: Map<K, V> {
pure fn size() -> uint { self.count }
fn contains_key(+k: K) -> bool {
fn contains_key(k: K) -> bool {
self.contains_key_ref(&k)
}
@ -213,7 +213,7 @@ pub mod chained {
}
}
fn insert(+k: K, +v: V) -> bool {
fn insert(k: K, +v: V) -> bool {
let hash = k.hash_keyed(0,0) as uint;
match self.search_tbl(&k, hash) {
NotFound => {
@ -255,7 +255,7 @@ pub mod chained {
}
}
pure fn find(+k: K) -> Option<V> {
pure fn find(k: K) -> Option<V> {
unsafe {
match self.search_tbl(&k, k.hash_keyed(0,0) as uint) {
NotFound => None,
@ -265,7 +265,7 @@ pub mod chained {
}
}
fn get(+k: K) -> V {
fn get(k: K) -> V {
let opt_v = self.find(k);
if opt_v.is_none() {
fail fmt!("Key not found in table: %?", k);
@ -273,7 +273,7 @@ pub mod chained {
option::unwrap(move opt_v)
}
fn remove(+k: K) -> bool {
fn remove(k: K) -> bool {
match self.search_tbl(&k, k.hash_keyed(0,0) as uint) {
NotFound => false,
FoundFirst(idx, entry) => {
@ -294,15 +294,15 @@ pub mod chained {
self.chains = chains(initial_capacity);
}
pure fn each(blk: fn(+key: K, +value: V) -> bool) {
pure fn each(blk: fn(key: K, +value: V) -> bool) {
self.each_ref(|k, v| blk(*k, *v))
}
pure fn each_key(blk: fn(+key: K) -> bool) {
pure fn each_key(blk: fn(key: K) -> bool) {
self.each_key_ref(|p| blk(*p))
}
pure fn each_value(blk: fn(+value: V) -> bool) {
pure fn each_value(blk: fn(value: V) -> bool) {
self.each_value_ref(|p| blk(*p))
}
@ -377,7 +377,7 @@ pub fn HashMap<K:Eq IterBytes Hash Const, V: Copy>()
}
/// Convenience function for adding keys to a hashmap with nil type keys
pub fn set_add<K:Eq IterBytes Hash Const Copy>(set: Set<K>, +key: K) -> bool {
pub fn set_add<K:Eq IterBytes Hash Const Copy>(set: Set<K>, key: K) -> bool {
set.insert(key, ())
}
@ -415,13 +415,13 @@ impl<K: Eq IterBytes Hash Copy, V: Copy> @Mut<LinearMap<K, V>>:
}
}
fn insert(+key: K, +value: V) -> bool {
fn insert(key: K, value: V) -> bool {
do self.borrow_mut |p| {
p.insert(key, value)
}
}
fn contains_key(+key: K) -> bool {
fn contains_key(key: K) -> bool {
do self.borrow_const |p| {
p.contains_key(&key)
}
@ -433,13 +433,13 @@ impl<K: Eq IterBytes Hash Copy, V: Copy> @Mut<LinearMap<K, V>>:
}
}
fn get(+key: K) -> V {
fn get(key: K) -> V {
do self.borrow_const |p| {
p.get(&key)
}
}
pure fn find(+key: K) -> Option<V> {
pure fn find(key: K) -> Option<V> {
unsafe {
do self.borrow_const |p| {
p.find(&key)
@ -447,7 +447,7 @@ impl<K: Eq IterBytes Hash Copy, V: Copy> @Mut<LinearMap<K, V>>:
}
}
fn remove(+key: K) -> bool {
fn remove(key: K) -> bool {
do self.borrow_mut |p| {
p.remove(&key)
}
@ -459,7 +459,7 @@ impl<K: Eq IterBytes Hash Copy, V: Copy> @Mut<LinearMap<K, V>>:
}
}
pure fn each(op: fn(+key: K, +value: V) -> bool) {
pure fn each(op: fn(key: K, +value: V) -> bool) {
unsafe {
do self.borrow_imm |p| {
p.each(|k, v| op(*k, *v))
@ -467,7 +467,7 @@ impl<K: Eq IterBytes Hash Copy, V: Copy> @Mut<LinearMap<K, V>>:
}
}
pure fn each_key(op: fn(+key: K) -> bool) {
pure fn each_key(op: fn(key: K) -> bool) {
unsafe {
do self.borrow_imm |p| {
p.each_key(|k| op(*k))
@ -475,7 +475,7 @@ impl<K: Eq IterBytes Hash Copy, V: Copy> @Mut<LinearMap<K, V>>:
}
}
pure fn each_value(op: fn(+value: V) -> bool) {
pure fn each_value(op: fn(value: V) -> bool) {
unsafe {
do self.borrow_imm |p| {
p.each_value(|v| op(*v))

View File

@ -129,7 +129,7 @@ enum TcpConnectErrData {
* the remote host. In the event of failure, a
* `net::tcp::tcp_connect_err_data` instance will be returned
*/
fn connect(+input_ip: ip::IpAddr, port: uint,
fn connect(input_ip: ip::IpAddr, port: uint,
iotask: IoTask)
-> result::Result<TcpSocket, TcpConnectErrData> unsafe {
let result_po = core::comm::Port::<ConnAttempt>();
@ -570,7 +570,7 @@ fn accept(new_conn: TcpNewConnection)
* successful/normal shutdown, and a `tcp_listen_err_data` enum in the event
* of listen exiting because of an error
*/
fn listen(+host_ip: ip::IpAddr, port: uint, backlog: uint,
fn listen(host_ip: ip::IpAddr, port: uint, backlog: uint,
iotask: IoTask,
+on_establish_cb: fn~(comm::Chan<Option<TcpErrData>>),
+new_connect_cb: fn~(TcpNewConnection,
@ -587,7 +587,7 @@ fn listen(+host_ip: ip::IpAddr, port: uint, backlog: uint,
}
}
fn listen_common(+host_ip: ip::IpAddr, port: uint, backlog: uint,
fn listen_common(host_ip: ip::IpAddr, port: uint, backlog: uint,
iotask: IoTask,
+on_establish_cb: fn~(comm::Chan<Option<TcpErrData>>),
+on_connect_cb: fn~(*uv::ll::uv_tcp_t))
@ -728,7 +728,7 @@ fn listen_common(+host_ip: ip::IpAddr, port: uint, backlog: uint,
*
* A buffered wrapper that you can cast as an `io::reader` or `io::writer`
*/
fn socket_buf(+sock: TcpSocket) -> TcpSocketBuf {
fn socket_buf(sock: TcpSocket) -> TcpSocketBuf {
TcpSocketBuf(@{ sock: move sock, mut buf: ~[] })
}
@ -738,7 +738,7 @@ impl TcpSocket {
result::Result<~[u8], TcpErrData>>, TcpErrData> {
read_start(&self)
}
fn read_stop(+read_port:
fn read_stop(read_port:
comm::Port<result::Result<~[u8], TcpErrData>>) ->
result::Result<(), TcpErrData> {
read_stop(&self, move read_port)
@ -1476,7 +1476,7 @@ mod test {
*/
}
fn buf_write<W:io::Writer>(+w: &W, val: &str) {
fn buf_write<W:io::Writer>(w: &W, val: &str) {
log(debug, fmt!("BUF_WRITE: val len %?", str::len(val)));
do str::byte_slice(val) |b_slice| {
log(debug, fmt!("BUF_WRITE: b_slice len %?",
@ -1485,7 +1485,7 @@ mod test {
}
}
fn buf_read<R:io::Reader>(+r: &R, len: uint) -> ~str {
fn buf_read<R:io::Reader>(r: &R, len: uint) -> ~str {
let new_bytes = (*r).read_bytes(len);
log(debug, fmt!("in buf_read.. new_bytes len: %?",
vec::len(new_bytes)));

View File

@ -1,5 +1,5 @@
//! Types/fns concerning URLs (see RFC 3986)
#[forbid(deprecated_mode)];
// tjc: forbid deprecated modes again after a snapshot
use core::cmp::Eq;
use map::HashMap;
@ -36,7 +36,7 @@ type UserInfo = {
type Query = ~[(~str, ~str)];
fn Url(+scheme: ~str, +user: Option<UserInfo>, +host: ~str,
fn Url(scheme: ~str, +user: Option<UserInfo>, +host: ~str,
+port: Option<~str>, +path: ~str, +query: Query,
+fragment: Option<~str>) -> Url {
Url { scheme: move scheme, user: move user, host: move host,
@ -44,7 +44,7 @@ fn Url(+scheme: ~str, +user: Option<UserInfo>, +host: ~str,
fragment: move fragment }
}
fn UserInfo(+user: ~str, +pass: Option<~str>) -> UserInfo {
fn UserInfo(user: ~str, +pass: Option<~str>) -> UserInfo {
{user: move user, pass: move pass}
}
@ -306,7 +306,7 @@ fn userinfo_from_str(uinfo: &str) -> UserInfo {
return UserInfo(user, pass);
}
fn userinfo_to_str(+userinfo: UserInfo) -> ~str {
fn userinfo_to_str(userinfo: UserInfo) -> ~str {
if option::is_some(&userinfo.pass) {
return str::concat(~[copy userinfo.user, ~":",
option::unwrap(copy userinfo.pass),
@ -334,7 +334,7 @@ fn query_from_str(rawquery: &str) -> Query {
return query;
}
fn query_to_str(+query: Query) -> ~str {
fn query_to_str(query: Query) -> ~str {
let mut strvec = ~[];
for query.each |kv| {
let (k, v) = copy *kv;
@ -681,7 +681,7 @@ impl Url : FromStr {
* result in just "http://somehost.com".
*
*/
fn to_str(+url: Url) -> ~str {
fn to_str(url: Url) -> ~str {
let user = if url.user.is_some() {
userinfo_to_str(option::unwrap(copy url.user))
} else {

View File

@ -379,7 +379,7 @@ Section: Iterating
* `true` If execution proceeded correctly, `false` if it was interrupted,
* that is if `it` returned `false` at any point.
*/
pub fn loop_chars(rope: Rope, it: fn(+c: char) -> bool) -> bool {
pub fn loop_chars(rope: Rope, it: fn(c: char) -> bool) -> bool {
match (rope) {
node::Empty => return true,
node::Content(x) => return node::loop_chars(x, it)
@ -1037,7 +1037,7 @@ mod node {
return result;
}
pub fn loop_chars(node: @Node, it: fn(+c: char) -> bool) -> bool {
pub fn loop_chars(node: @Node, it: fn(c: char) -> bool) -> bool {
return loop_leaves(node,|leaf| {
str::all_between(*leaf.content,
leaf.byte_offset,

View File

@ -2,7 +2,7 @@
* A simple map based on a vector for small integer keys. Space requirements
* are O(highest integer key).
*/
#[forbid(deprecated_mode)];
// tjc: forbid deprecated modes again after snap
use core::option;
use core::option::{Some, None};
@ -28,7 +28,7 @@ pub fn mk<T: Copy>() -> SmallIntMap<T> {
* the specified key then the original value is replaced.
*/
#[inline(always)]
pub fn insert<T: Copy>(self: SmallIntMap<T>, key: uint, +val: T) {
pub fn insert<T: Copy>(self: SmallIntMap<T>, key: uint, val: T) {
//io::println(fmt!("%?", key));
self.v.grow_set_elt(key, &None, Some(val));
}
@ -77,12 +77,12 @@ impl<V: Copy> SmallIntMap<V>: map::Map<uint, V> {
sz
}
#[inline(always)]
fn insert(+key: uint, +value: V) -> bool {
fn insert(key: uint, value: V) -> bool {
let exists = contains_key(self, key);
insert(self, key, value);
return !exists;
}
fn remove(+key: uint) -> bool {
fn remove(key: uint) -> bool {
if key >= self.v.len() {
return false;
}
@ -93,23 +93,23 @@ impl<V: Copy> SmallIntMap<V>: map::Map<uint, V> {
fn clear() {
self.v.set(~[]);
}
fn contains_key(+key: uint) -> bool {
fn contains_key(key: uint) -> bool {
contains_key(self, key)
}
fn contains_key_ref(key: &uint) -> bool {
contains_key(self, *key)
}
fn get(+key: uint) -> V { get(self, key) }
pure fn find(+key: uint) -> Option<V> { find(self, key) }
fn get(key: uint) -> V { get(self, key) }
pure fn find(key: uint) -> Option<V> { find(self, key) }
fn rehash() { fail }
pure fn each(it: fn(+key: uint, +value: V) -> bool) {
pure fn each(it: fn(key: uint, +value: V) -> bool) {
self.each_ref(|k, v| it(*k, *v))
}
pure fn each_key(it: fn(+key: uint) -> bool) {
pure fn each_key(it: fn(key: uint) -> bool) {
self.each_ref(|k, _v| it(*k))
}
pure fn each_value(it: fn(+value: V) -> bool) {
pure fn each_value(it: fn(value: V) -> bool) {
self.each_ref(|_k, v| it(*v))
}
pure fn each_ref(it: fn(key: &uint, value: &V) -> bool) {

View File

@ -18,9 +18,6 @@ not required in or otherwise suitable for the core library.
#[no_core];
// tjc: Added legacy_modes back in because it still uses + mode.
// Remove once + mode gets expunged from std.
#[legacy_modes];
#[legacy_exports];
#[allow(vecs_implicitly_copyable)];

View File

@ -1,5 +1,5 @@
// NB: transitionary, de-mode-ing.
#[forbid(deprecated_mode)];
// tjc: forbid deprecated modes again after snap
/**
* The concurrency primitives you know and love.
*
@ -69,7 +69,7 @@ struct SemInner<Q> {
enum Sem<Q: Send> = Exclusive<SemInner<Q>>;
#[doc(hidden)]
fn new_sem<Q: Send>(count: int, +q: Q) -> Sem<Q> {
fn new_sem<Q: Send>(count: int, q: Q) -> Sem<Q> {
Sem(exclusive(SemInner {
mut count: count, waiters: new_waitqueue(), blocked: q }))
}
@ -535,7 +535,7 @@ impl &RWlock {
* }
* ~~~
*/
fn write_downgrade<U>(blk: fn(+v: RWlockWriteMode) -> U) -> U {
fn write_downgrade<U>(blk: fn(v: RWlockWriteMode) -> U) -> U {
// Implementation slightly different from the slicker 'write's above.
// The exit path is conditional on whether the caller downgrades.
let mut _release = None;
@ -551,7 +551,7 @@ impl &RWlock {
}
/// To be called inside of the write_downgrade block.
fn downgrade(+token: RWlockWriteMode/&a) -> RWlockReadMode/&a {
fn downgrade(token: RWlockWriteMode/&a) -> RWlockReadMode/&a {
if !ptr::ref_eq(self, token.lock) {
fail ~"Can't downgrade() with a different rwlock's write_mode!";
}
@ -957,7 +957,7 @@ mod tests {
drop { self.c.send(()); }
}
fn SendOnFailure(+c: pipes::Chan<()>) -> SendOnFailure {
fn SendOnFailure(c: pipes::Chan<()>) -> SendOnFailure {
SendOnFailure {
c: c
}
@ -1038,7 +1038,7 @@ mod tests {
}
}
#[cfg(test)]
fn test_rwlock_exclusion(+x: ~RWlock, mode1: RWlockMode,
fn test_rwlock_exclusion(x: ~RWlock, mode1: RWlockMode,
mode2: RWlockMode) {
// Test mutual exclusion between readers and writers. Just like the
// mutex mutual exclusion test, a ways above.
@ -1083,7 +1083,7 @@ mod tests {
test_rwlock_exclusion(~RWlock(), Downgrade, Downgrade);
}
#[cfg(test)]
fn test_rwlock_handshake(+x: ~RWlock, mode1: RWlockMode,
fn test_rwlock_handshake(x: ~RWlock, mode1: RWlockMode,
mode2: RWlockMode, make_mode2_go_first: bool) {
// Much like sem_multi_resource.
let x2 = ~x.clone();

View File

@ -270,7 +270,7 @@ enum TestEvent {
type MonitorMsg = (TestDesc, TestResult);
fn run_tests(opts: &TestOpts, tests: &[TestDesc],
callback: fn@(+e: TestEvent)) {
callback: fn@(e: TestEvent)) {
let mut filtered_tests = filter_tests(opts, tests);
callback(TeFiltered(copy filtered_tests));
@ -379,7 +379,7 @@ fn filter_tests(opts: &TestOpts,
type TestFuture = {test: TestDesc, wait: fn@() -> TestResult};
fn run_test(+test: TestDesc, monitor_ch: comm::Chan<MonitorMsg>) {
fn run_test(test: TestDesc, monitor_ch: comm::Chan<MonitorMsg>) {
if test.ignore {
core::comm::send(monitor_ch, (copy test, TrIgnored));
return;

View File

@ -1,4 +1,4 @@
#[forbid(deprecated_mode)];
// tjc: forbid deprecated modes again after snap
use core::cmp::Eq;
use libc::{c_char, c_int, c_long, size_t, time_t};
@ -589,7 +589,7 @@ pub fn strptime(s: &str, format: &str) -> Result<Tm, ~str> {
}
}
fn strftime(format: &str, +tm: Tm) -> ~str {
fn strftime(format: &str, tm: Tm) -> ~str {
fn parse_type(ch: char, tm: &Tm) -> ~str {
//FIXME (#2350): Implement missing types.
let die = || #fmt("strftime: can't understand this format %c ",

View File

@ -1,6 +1,6 @@
//! Utilities that leverage libuv's `uv_timer_*` API
#[forbid(deprecated_mode)];
// tjc: forbid deprecated modes again after snap
use uv = uv;
use uv::iotask;
@ -24,7 +24,7 @@ use comm = core::comm;
* * val - a value of type T to send over the provided `ch`
*/
pub fn delayed_send<T: Copy Send>(iotask: IoTask,
msecs: uint, ch: comm::Chan<T>, +val: T) {
msecs: uint, ch: comm::Chan<T>, val: T) {
unsafe {
let timer_done_po = core::comm::Port::<()>();
let timer_done_ch = core::comm::Chan(timer_done_po);

View File

@ -5,7 +5,7 @@
* `interact` function you can execute code in a uv callback.
*/
#[forbid(deprecated_mode)];
// tjc: forbid deprecated modes again after a snapshot
use libc::c_void;
use ptr::p2::addr_of;
@ -22,7 +22,7 @@ pub enum IoTask {
})
}
pub fn spawn_iotask(+task: task::TaskBuilder) -> IoTask {
pub fn spawn_iotask(task: task::TaskBuilder) -> IoTask {
do listen |iotask_ch| {

View File

@ -642,7 +642,7 @@ extern mod rustrt {
fn rust_uv_addrinfo_as_sockaddr_in(input: *addrinfo) -> *sockaddr_in;
fn rust_uv_addrinfo_as_sockaddr_in6(input: *addrinfo) -> *sockaddr_in6;
fn rust_uv_malloc_buf_base_of(sug_size: libc::size_t) -> *u8;
fn rust_uv_free_base_of_buf(++buf: uv_buf_t);
fn rust_uv_free_base_of_buf(+buf: uv_buf_t);
fn rust_uv_get_stream_handle_from_connect_req(
connect_req: *uv_connect_t)
-> *uv_stream_t;
@ -661,8 +661,8 @@ extern mod rustrt {
fn rust_uv_get_data_for_req(req: *libc::c_void) -> *libc::c_void;
fn rust_uv_set_data_for_req(req: *libc::c_void,
data: *libc::c_void);
fn rust_uv_get_base_from_buf(++buf: uv_buf_t) -> *u8;
fn rust_uv_get_len_from_buf(++buf: uv_buf_t) -> libc::size_t;
fn rust_uv_get_base_from_buf(+buf: uv_buf_t) -> *u8;
fn rust_uv_get_len_from_buf(+buf: uv_buf_t) -> libc::size_t;
// sizeof testing helpers
fn rust_uv_helper_uv_tcp_t_size() -> libc::c_uint;

View File

@ -251,7 +251,7 @@ fn pbfs(&&graph: arc::ARC<graph>, key: node_id) -> bfs_result {
colors = do par::mapi_factory(*color_vec) {
let colors = arc::clone(&color);
let graph = arc::clone(&graph);
fn~(i: uint, c: color) -> color {
fn~(+i: uint, +c: color) -> color {
let c : color = c;
let colors = arc::get(&colors);
let graph = arc::get(&graph);