This commit mostly replaces some of the uses of os::args with env::args.
//! Implementation of the `build` subcommand, used to compile a book.
use std::os;
+use std::env;
use std::old_io;
use std::old_io::{fs, File, BufferedWriter, TempDir, IoResult};
let out_path = tgt.join(item.path.dirname());
let src;
- if os::args().len() < 3 {
+ if env::args().len() < 3 {
src = os::getcwd().unwrap().clone();
} else {
- src = Path::new(os::args()[2].clone());
+ src = Path::new(env::args().nth(2).unwrap().clone());
}
// preprocess the markdown, rerouting markdown references to html references
let markdown_data = try!(File::open(&src.join(&item.path)).read_to_string());
let src;
let tgt;
- if os::args().len() < 3 {
+ if env::args().len() < 3 {
src = cwd.clone();
} else {
- src = Path::new(os::args()[2].clone());
+ src = Path::new(env::args().nth(2).unwrap().clone());
}
- if os::args().len() < 4 {
+ if env::args().len() < 4 {
tgt = cwd.join("_book");
} else {
- tgt = Path::new(os::args()[3].clone());
+ tgt = Path::new(env::args().nth(3).unwrap().clone());
}
try!(fs::mkdir(&tgt, old_io::USER_DIR));
#![feature(core)]
#![feature(io)]
#![feature(os)]
+#![feature(env)]
#![feature(path)]
#![feature(rustdoc)]
extern crate rustdoc;
-use std::os;
+use std::env;
use subcommand::Subcommand;
use term::Term;
#[cfg(not(test))] // thanks #12327
fn main() {
let mut term = Term::new();
- let cmd = os::args();
+ let cmd: Vec<_> = env::args().collect();
if cmd.len() < 1 {
help::usage()
//! An abstraction of the terminal. Eventually, provide color and
//! verbosity support. For now, just a wrapper around stdout/stderr.
-use std::os;
+use std::env;
use std::old_io::stdio;
pub struct Term {
pub fn err(&mut self, msg: &str) {
// swallow any errors
let _ = self.err.write_line(msg);
- os::set_exit_status(101);
+ env::set_exit_status(101);
}
}
#![feature(unboxed_closures)]
use std::collections::{BTreeMap, HashMap, HashSet};
-use std::os;
+use std::env;
use std::rand::{Rng, IsaacRng, SeedableRng};
use std::time::Duration;
}
trait MutableMap {
- fn insert(&mut self, k: uint, v: uint);
- fn remove(&mut self, k: &uint) -> bool;
- fn find(&self, k: &uint) -> Option<&uint>;
+ fn insert(&mut self, k: usize, v: usize);
+ fn remove(&mut self, k: &usize) -> bool;
+ fn find(&self, k: &usize) -> Option<&usize>;
}
-impl MutableMap for BTreeMap<uint, uint> {
- fn insert(&mut self, k: uint, v: uint) { self.insert(k, v); }
- fn remove(&mut self, k: &uint) -> bool { self.remove(k).is_some() }
- fn find(&self, k: &uint) -> Option<&uint> { self.get(k) }
+impl MutableMap for BTreeMap<usize, usize> {
+ fn insert(&mut self, k: usize, v: usize) { self.insert(k, v); }
+ fn remove(&mut self, k: &usize) -> bool { self.remove(k).is_some() }
+ fn find(&self, k: &usize) -> Option<&usize> { self.get(k) }
}
-impl MutableMap for HashMap<uint, uint> {
- fn insert(&mut self, k: uint, v: uint) { self.insert(k, v); }
- fn remove(&mut self, k: &uint) -> bool { self.remove(k).is_some() }
- fn find(&self, k: &uint) -> Option<&uint> { self.get(k) }
+impl MutableMap for HashMap<usize, usize> {
+ fn insert(&mut self, k: usize, v: usize) { self.insert(k, v); }
+ fn remove(&mut self, k: &usize) -> bool { self.remove(k).is_some() }
+ fn find(&self, k: &usize) -> Option<&usize> { self.get(k) }
}
-fn ascending<M: MutableMap>(map: &mut M, n_keys: uint) {
+fn ascending<M: MutableMap>(map: &mut M, n_keys: usize) {
println!(" Ascending integers:");
timed("insert", || {
- for i in 0u..n_keys {
+ for i in 0..n_keys {
map.insert(i, i + 1);
}
});
timed("search", || {
- for i in 0u..n_keys {
+ for i in 0..n_keys {
assert_eq!(map.find(&i).unwrap(), &(i + 1));
}
});
});
}
-fn descending<M: MutableMap>(map: &mut M, n_keys: uint) {
+fn descending<M: MutableMap>(map: &mut M, n_keys: usize) {
println!(" Descending integers:");
timed("insert", || {
});
}
-fn vector<M: MutableMap>(map: &mut M, n_keys: uint, dist: &[uint]) {
+fn vector<M: MutableMap>(map: &mut M, n_keys: usize, dist: &[usize]) {
timed("insert", || {
- for i in 0u..n_keys {
+ for i in 0..n_keys {
map.insert(dist[i], i + 1);
}
});
timed("search", || {
- for i in 0u..n_keys {
+ for i in 0..n_keys {
assert_eq!(map.find(&dist[i]).unwrap(), &(i + 1));
}
});
timed("remove", || {
- for i in 0u..n_keys {
+ for i in 0..n_keys {
assert!(map.remove(&dist[i]));
}
});
}
fn main() {
- let args = os::args();
- let args = args;
+ let mut args = env::args();
let n_keys = {
if args.len() == 2 {
- args[1].parse::<uint>().unwrap()
+ args.nth(1).unwrap().parse::<usize>().unwrap()
} else {
1000000
}
println!("{}", "\nBTreeMap:");
{
- let mut map: BTreeMap<uint,uint> = BTreeMap::new();
+ let mut map: BTreeMap<usize,usize> = BTreeMap::new();
ascending(&mut map, n_keys);
}
{
- let mut map: BTreeMap<uint,uint> = BTreeMap::new();
+ let mut map: BTreeMap<usize,usize> = BTreeMap::new();
descending(&mut map, n_keys);
}
{
println!(" Random integers:");
- let mut map: BTreeMap<uint,uint> = BTreeMap::new();
+ let mut map: BTreeMap<usize,usize> = BTreeMap::new();
vector(&mut map, n_keys, &rand);
}
println!("{}", "\nHashMap:");
{
- let mut map: HashMap<uint,uint> = HashMap::new();
+ let mut map: HashMap<usize,usize> = HashMap::new();
ascending(&mut map, n_keys);
}
{
- let mut map: HashMap<uint,uint> = HashMap::new();
+ let mut map: HashMap<usize,usize> = HashMap::new();
descending(&mut map, n_keys);
}
{
println!(" Random integers:");
- let mut map: HashMap<uint,uint> = HashMap::new();
+ let mut map: HashMap<usize,usize> = HashMap::new();
vector(&mut map, n_keys, &rand);
}
}
use std::collections::HashSet;
use std::collections::hash_map::Hasher;
use std::hash::Hash;
-use std::os;
+use std::env;
use std::time::Duration;
struct Results {
fn remove(&mut self, k: &T) -> bool { self.remove(k) }
fn contains(&self, k: &T) -> bool { self.contains(k) }
}
-impl MutableSet<uint> for BitvSet {
- fn insert(&mut self, k: uint) { self.insert(k); }
- fn remove(&mut self, k: &uint) -> bool { self.remove(k) }
- fn contains(&self, k: &uint) -> bool { self.contains(k) }
+impl MutableSet<usize> for BitvSet {
+ fn insert(&mut self, k: usize) { self.insert(k); }
+ fn remove(&mut self, k: &usize) -> bool { self.remove(k) }
+ fn contains(&self, k: &usize) -> bool { self.contains(k) }
}
impl Results {
- pub fn bench_int<T:MutableSet<uint>,
+ pub fn bench_int<T:MutableSet<usize>,
R:rand::Rng,
F:FnMut() -> T>(
&mut self,
rng: &mut R,
- num_keys: uint,
- rand_cap: uint,
+ num_keys: usize,
+ rand_cap: usize,
mut f: F) {
{
let mut set = f();
timed(&mut self.sequential_ints, || {
- for i in 0u..num_keys {
+ for i in 0..num_keys {
set.insert(i);
}
- for i in 0u..num_keys {
+ for i in 0..num_keys {
assert!(set.contains(&i));
}
})
let mut set = f();
timed(&mut self.random_ints, || {
for _ in 0..num_keys {
- set.insert(rng.gen::<uint>() % rand_cap);
+ set.insert(rng.gen::<usize>() % rand_cap);
}
})
}
{
let mut set = f();
- for i in 0u..num_keys {
+ for i in 0..num_keys {
set.insert(i);
}
timed(&mut self.delete_ints, || {
- for i in 0u..num_keys {
+ for i in 0..num_keys {
assert!(set.remove(&i));
}
})
F:FnMut() -> T>(
&mut self,
rng: &mut R,
- num_keys: uint,
+ num_keys: usize,
mut f: F) {
{
let mut set = f();
timed(&mut self.sequential_strings, || {
- for i in 0u..num_keys {
+ for i in 0..num_keys {
set.insert(i.to_string());
}
- for i in 0u..num_keys {
+ for i in 0..num_keys {
assert!(set.contains(&i.to_string()));
}
})
let mut set = f();
timed(&mut self.random_strings, || {
for _ in 0..num_keys {
- let s = rng.gen::<uint>().to_string();
+ let s = rng.gen::<usize>().to_string();
set.insert(s);
}
})
{
let mut set = f();
- for i in 0u..num_keys {
+ for i in 0..num_keys {
set.insert(i.to_string());
}
timed(&mut self.delete_strings, || {
- for i in 0u..num_keys {
+ for i in 0..num_keys {
assert!(set.remove(&i.to_string()));
}
})
}
fn main() {
- let args = os::args();
- let args = args;
+ let mut args = env::args();
let num_keys = {
if args.len() == 2 {
- args[1].parse::<uint>().unwrap()
+ args.nth(1).unwrap().parse::<usize>().unwrap()
} else {
100 // woefully inadequate for any real measurement
}
let mut rng: rand::IsaacRng = rand::SeedableRng::from_seed(seed);
let mut results = empty_results();
results.bench_int(&mut rng, num_keys, max, || {
- let s: HashSet<uint> = HashSet::new();
+ let s: HashSet<usize> = HashSet::new();
s
});
results.bench_str(&mut rng, num_keys, || {
let mut rng: rand::IsaacRng = rand::SeedableRng::from_seed(seed);
let mut results = empty_results();
results.bench_int(&mut rng, num_keys, max, || {
- let s: BTreeSet<uint> = BTreeSet::new();
+ let s: BTreeSet<usize> = BTreeSet::new();
s
});
results.bench_str(&mut rng, num_keys, || {
use std::old_io::File;
use std::iter::repeat;
use std::mem::swap;
-use std::os;
use std::env;
use std::rand::Rng;
use std::rand;
use std::vec;
fn main() {
- let argv = os::args();
- let _tests = &argv[1..argv.len()];
+ let argv: Vec<String> = env::args().collect();
macro_rules! bench {
($id:ident) =>
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use std::os;
use std::env;
fn main() {
- let args = os::args();
+ let args = env::args();
let args = if env::var_os("RUST_BENCH").is_some() {
vec!("".to_string(), "10000000".to_string())
} else if args.len() <= 1u {
vec!("".to_string(), "100000".to_string())
} else {
- args.into_iter().collect()
+ args.collect()
};
let n = args[1].parse().unwrap();
// version.
use std::sync::mpsc::{channel, Sender, Receiver};
-use std::os;
use std::env;
use std::thread::Thread;
use std::time::Duration;
}
fn main() {
- let args = os::args();
+ let args = env::args();
let args = if env::var_os("RUST_BENCH").is_some() {
vec!("".to_string(), "1000000".to_string(), "10000".to_string())
- } else if args.len() <= 1u {
+ } else if args.len() <= 1 {
vec!("".to_string(), "10000".to_string(), "4".to_string())
} else {
- args.into_iter().map(|x| x.to_string()).collect()
+ args.map(|x| x.to_string()).collect()
};
println!("{:?}", args);
// I *think* it's the same, more or less.
use std::sync::mpsc::{channel, Sender, Receiver};
-use std::os;
use std::env;
use std::thread::Thread;
use std::time::Duration;
}
fn main() {
- let args = os::args();
+ let args = env::args();
let args = if env::var_os("RUST_BENCH").is_some() {
vec!("".to_string(), "1000000".to_string(), "8".to_string())
- } else if args.len() <= 1u {
+ } else if args.len() <= 1 {
vec!("".to_string(), "10000".to_string(), "4".to_string())
} else {
- args.clone().into_iter().map(|x| x.to_string()).collect()
+ args.map(|x| x.to_string()).collect()
};
println!("{:?}", args);
// no-pretty-expanded FIXME #15189
// ignore-lexer-test FIXME #15679
-use std::os;
use std::env;
use std::sync::{Arc, Future, Mutex, Condvar};
use std::time::Duration;
}
fn main() {
- let args = os::args();
+ let args = env::args();
let args = if env::var_os("RUST_BENCH").is_some() {
vec!("".to_string(), "100".to_string(), "10000".to_string())
- } else if args.len() <= 1u {
+ } else if args.len() <= 1 {
vec!("".to_string(), "10".to_string(), "100".to_string())
} else {
- args.clone().into_iter().collect()
+ args.collect()
};
let num_tasks = args[1].parse::<uint>().unwrap();
// except according to those terms.
use std::sync::mpsc::channel;
-use std::os;
+use std::env;
use std::thread::Thread;
// This is a simple bench that creates M pairs of tasks. These
// canonical message-passing benchmark as it heavily strains message
// passing and almost nothing else.
-fn ping_pong_bench(n: uint, m: uint) {
+fn ping_pong_bench(n: usize, m: usize) {
// Create pairs of tasks that pingpong back and forth.
- fn run_pair(n: uint) {
+ fn run_pair(n: usize) {
// Create a channel: A->B
let (atx, arx) = channel();
// Create a channel: B->A
fn main() {
-
- let args = os::args();
- let args = args;
- let n = if args.len() == 3 {
- args[1].parse::<uint>().unwrap()
- } else {
- 10000
- };
-
- let m = if args.len() == 3 {
- args[2].parse::<uint>().unwrap()
+ let mut args = env::args();
+ let (n, m) = if args.len() == 3 {
+ let n = args.nth(1).unwrap().parse::<usize>().unwrap();
+ let m = args.next().unwrap().parse::<usize>().unwrap();
+ (n, m)
} else {
- 4
+ (10000, 4)
};
ping_pong_bench(n, m);
// except according to those terms.
use std::sync::mpsc::channel;
-use std::os;
+use std::env;
use std::thread::Thread;
// A simple implementation of parfib. One subtree is found in a new
// task and communicated over a oneshot pipe, the other is found
// locally. There is no sequential-mode threshold.
-fn parfib(n: uint) -> uint {
+fn parfib(n: u64) -> u64 {
if n == 0 || n == 1 {
return 1;
}
}
fn main() {
-
- let args = os::args();
- let args = args;
+ let mut args = env::args();
let n = if args.len() == 2 {
- args[1].parse::<uint>().unwrap()
+ args.nth(1).unwrap().parse::<u64>().unwrap()
} else {
10
};
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use std::os;
use std::env;
-fn ack(m: int, n: int) -> int {
+fn ack(m: i64, n: i64) -> i64 {
if m == 0 {
return n + 1
} else {
}
fn main() {
- let args = os::args();
+ let mut args = env::args();
let args = if env::var_os("RUST_BENCH").is_some() {
vec!("".to_string(), "12".to_string())
- } else if args.len() <= 1u {
+ } else if args.len() <= 1 {
vec!("".to_string(), "8".to_string())
} else {
- args.into_iter().collect()
+ args.collect()
};
let n = args[1].parse().unwrap();
println!("Ack(3,{}): {}\n", n, ack(3, n));
}
fn main() {
- let args = std::os::args();
- let args = args;
+ let mut args = std::env::args();
let n = if std::env::var_os("RUST_BENCH").is_some() {
17
- } else if args.len() <= 1u {
+ } else if args.len() <= 1 {
8
} else {
- args[1].parse().unwrap()
+ args.nth(1).unwrap().parse().unwrap()
};
let min_depth = 4;
let max_depth = if min_depth + 2 > n {min_depth + 2} else {n};
let nn = if std::env::var_os("RUST_BENCH").is_some() {
200000
} else {
- std::os::args()
- .get(1)
+ std::env::args()
+ .nth(1)
.and_then(|arg| arg.parse().ok())
- .unwrap_or(600u)
+ .unwrap_or(600us)
};
print_complements();
}
fn main() {
- let n = std::os::args()
- .get(1)
+ let n = std::env::args()
+ .nth(1)
.and_then(|arg| arg.parse().ok())
.unwrap_or(2i32);
use std::cmp::min;
use std::old_io::{stdout, IoResult};
use std::iter::repeat;
-use std::os;
+use std::env;
use std::slice::bytes::copy_memory;
-const LINE_LEN: uint = 60;
-const LOOKUP_SIZE: uint = 4 * 1024;
+const LINE_LEN: usize = 60;
+const LOOKUP_SIZE: usize = 4 * 1024;
const LOOKUP_SCALE: f32 = (LOOKUP_SIZE - 1) as f32;
// Random number generator constants
RepeatFasta { alu: alu, out: w }
}
- fn make(&mut self, n: uint) -> IoResult<()> {
+ fn make(&mut self, n: usize) -> IoResult<()> {
let alu_len = self.alu.len();
let mut buf = repeat(0u8).take(alu_len + LINE_LEN).collect::<Vec<_>>();
let alu: &[u8] = self.alu.as_bytes();
0
}
- fn make(&mut self, n: uint) -> IoResult<()> {
+ fn make(&mut self, n: usize) -> IoResult<()> {
let lines = n / LINE_LEN;
let chars_left = n % LINE_LEN;
let mut buf = [0;LINE_LEN + 1];
for _ in 0..lines {
- for i in 0u..LINE_LEN {
+ for i in 0..LINE_LEN {
buf[i] = self.nextc();
}
buf[LINE_LEN] = '\n' as u8;
try!(self.out.write(&buf));
}
- for i in 0u..chars_left {
+ for i in 0..chars_left {
buf[i] = self.nextc();
}
self.out.write(&buf[..chars_left])
}
fn main() {
- let args = os::args();
- let args = args;
+ let mut args = env::args();
let n = if args.len() > 1 {
- args[1].parse::<uint>().unwrap()
+ args.nth(1).unwrap().parse::<usize>().unwrap()
} else {
5
};
use std::old_io::{BufferedWriter, File};
use std::old_io;
use std::num::Float;
-use std::os;
use std::env;
-const LINE_LENGTH: uint = 60;
+const LINE_LENGTH: usize = 60;
const IM: u32 = 139968;
struct MyRandom {
}
fn make_fasta<W: Writer, I: Iterator<Item=u8>>(
- wr: &mut W, header: &str, mut it: I, mut n: uint)
+ wr: &mut W, header: &str, mut it: I, mut n: usize)
-> std::old_io::IoResult<()>
{
try!(wr.write(header.as_bytes()));
}
fn run<W: Writer>(writer: &mut W) -> std::old_io::IoResult<()> {
- let args = os::args();
- let args = args;
+ let mut args = env::args();
let n = if env::var_os("RUST_BENCH").is_some() {
25000000
- } else if args.len() <= 1u {
+ } else if args.len() <= 1 {
1000
} else {
- args[1].parse().unwrap()
+ args.nth(1).unwrap().parse().unwrap()
};
let rng = &mut MyRandom::new();
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use std::os;
use std::env;
-fn fib(n: int) -> int {
+fn fib(n: i64) -> i64 {
if n < 2 {
return 1;
} else {
}
fn main() {
- let args = os::args();
+ let args = env::args();
let args = if env::var_os("RUST_BENCH").is_some() {
vec!("".to_string(), "40".to_string())
- } else if args.len() <= 1u {
+ } else if args.len() <= 1 {
vec!("".to_string(), "30".to_string())
} else {
- args.into_iter().collect()
+ args.collect()
};
let n = args[1].parse().unwrap();
println!("{}\n", fib(n));
// ignore-pretty very bad with line comments
use std::old_io;
-use std::os;
+use std::env;
use std::simd::f64x2;
use std::sync::Arc;
use std::thread::Thread;
}
fn main() {
- let args = os::args();
+ let mut args = env::args();
let res = if args.len() < 2 {
println!("Test mode: do not dump the image because it's not utf8, \
which interferes with the test runner.");
mandelbrot(1000, old_io::util::NullWriter)
} else {
- mandelbrot(args[1].parse().unwrap(), old_io::stdout())
+ mandelbrot(args.nth(1).unwrap().parse().unwrap(), old_io::stdout())
};
res.unwrap();
}
let n = if std::env::var_os("RUST_BENCH").is_some() {
5000000
} else {
- std::os::args().get(1)
+ std::env::args().nth(1)
.and_then(|arg| arg.parse().ok())
.unwrap_or(1000)
};
extern crate getopts;
use std::sync::mpsc::{channel, Sender};
-use std::os;
use std::env;
use std::result::Result::{Ok, Err};
use std::thread::Thread;
use std::time::Duration;
-fn fib(n: int) -> int {
- fn pfib(tx: &Sender<int>, n: int) {
+fn fib(n: isize) -> isize {
+ fn pfib(tx: &Sender<isize>, n: isize) {
if n == 0 {
tx.send(0).unwrap();
} else if n <= 2 {
}
}
-fn stress_task(id: int) {
+fn stress_task(id: isize) {
let mut i = 0;
loop {
let n = 15;
}
fn main() {
- let args = os::args();
+ let args = env::args();
let args = if env::var_os("RUST_BENCH").is_some() {
vec!("".to_string(), "20".to_string())
- } else if args.len() <= 1u {
+ } else if args.len() <= 1 {
vec!("".to_string(), "8".to_string())
} else {
- args.into_iter().map(|x| x.to_string()).collect()
+ args.map(|x| x.to_string()).collect()
};
let opts = parse_opts(args.clone());
if opts.stress {
stress(2);
} else {
- let max = args[1].parse::<int>().unwrap();
+ let max = args[1].parse::<isize>().unwrap();
let num_trials = 10;
for n in 1..max + 1 {
- for _ in 0u..num_trials {
+ for _ in 0..num_trials {
let mut fibn = None;
let dur = Duration::span(|| fibn = Some(fib(n)));
let fibn = fibn.unwrap();
use std::simd::f64x2;
fn main() {
- let args = os::args();
+ let mut args = env::args();
let answer = spectralnorm(if env::var_os("RUST_BENCH").is_some() {
5500
} else if args.len() < 2 {
2000
} else {
- args[1].parse().unwrap()
+ args.nth(1).unwrap().parse().unwrap()
});
println!("{:.9}", answer);
}
}
fn main() {
- let args = std::os::args();
+ let mut args = std::env::args();
let token = if std::env::var_os("RUST_BENCH").is_some() {
2000000
} else {
- args.get(1).and_then(|arg| arg.parse().ok()).unwrap_or(1000)
+ args.nth(1).and_then(|arg| arg.parse().ok()).unwrap_or(1000)
};
- let n_tasks = args.get(2)
+ let n_tasks = args.next()
.and_then(|arg| arg.parse().ok())
.unwrap_or(503);
// Microbenchmark for the smallintmap library
use std::collections::VecMap;
-use std::os;
use std::env;
use std::time::Duration;
-fn append_sequential(min: uint, max: uint, map: &mut VecMap<uint>) {
+fn append_sequential(min: usize, max: usize, map: &mut VecMap<usize>) {
for i in min..max {
- map.insert(i, i + 22u);
+ map.insert(i, i + 22);
}
}
-fn check_sequential(min: uint, max: uint, map: &VecMap<uint>) {
+fn check_sequential(min: usize, max: usize, map: &VecMap<usize>) {
for i in min..max {
- assert_eq!(map[i], i + 22u);
+ assert_eq!(map[i], i + 22);
}
}
fn main() {
- let args = os::args();
+ let args = env::args();
let args = if env::var_os("RUST_BENCH").is_some() {
vec!("".to_string(), "100000".to_string(), "100".to_string())
- } else if args.len() <= 1u {
+ } else if args.len() <= 1 {
vec!("".to_string(), "10000".to_string(), "50".to_string())
} else {
- args.into_iter().collect()
+ args.collect()
};
- let max = args[1].parse::<uint>().unwrap();
- let rep = args[2].parse::<uint>().unwrap();
+ let max = args[1].parse::<usize>().unwrap();
+ let rep = args[2].parse::<usize>().unwrap();
let mut checkf = Duration::seconds(0);
let mut appendf = Duration::seconds(0);
- for _ in 0u..rep {
+ for _ in 0..rep {
let mut map = VecMap::new();
- let d1 = Duration::span(|| append_sequential(0u, max, &mut map));
- let d2 = Duration::span(|| check_sequential(0u, max, &map));
+ let d1 = Duration::span(|| append_sequential(0, max, &mut map));
+ let d2 = Duration::span(|| check_sequential(0, max, &map));
checkf = checkf + d2;
appendf = appendf + d1;
use std::old_io;
use std::iter::repeat;
use std::num::Int;
-use std::os;
+use std::env;
// Computes a single solution to a given 9x9 sudoku
//
}
fn main() {
- let args = os::args();
- let use_default = args.len() == 1u;
+ let args = env::args();
+ let use_default = args.len() == 1;
let mut sudoku = if use_default {
Sudoku::from_vec(&DEFAULT_SUDOKU)
} else {
// ignore-pretty very bad with line comments
use std::sync::mpsc::{channel, Sender};
-use std::os;
use std::env;
use std::thread::Thread;
}
fn main() {
- let args = os::args();
+ let args = env::args();
let args = if env::var_os("RUST_BENCH").is_some() {
vec!("".to_string(), "100000".to_string())
} else if args.len() <= 1 {
vec!("".to_string(), "100".to_string())
} else {
- args.clone().into_iter().collect()
+ args.collect()
};
let (tx, rx) = channel();
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use std::os;
use std::env;
use std::thread::Thread;
-fn f(n: uint) {
+fn f(n: usize) {
let mut i = 0u;
while i < n {
let _ = Thread::scoped(move|| g()).join();
fn g() { }
fn main() {
- let args = os::args();
+ let args = env::args();
let args = if env::var_os("RUST_BENCH").is_some() {
vec!("".to_string(), "400".to_string())
- } else if args.len() <= 1u {
+ } else if args.len() <= 1 {
vec!("".to_string(), "10".to_string())
} else {
- args.into_iter().collect()
+ args.collect()
};
let n = args[1].parse().unwrap();
- let mut i = 0u;
+ let mut i = 0;
while i < n { Thread::spawn(move|| f(n) ); i += 1u; }
}
// error-pattern:nonzero
// exec-env:RUST_NEWRT=1
-use std::os;
+use std::env;
fn main() {
- os::args();
+ env::args();
panic!("please have a nonzero exit status");
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use std::os;
+use std::env;
use std::old_io::{File, Command};
// creates broken.rs, which has the Ident \x00name_0,ctxt_0\x00
// provided `rustc`
fn main() {
- let args = os::args();
+ let args: Vec<String> = env::args().collect();
let rustc = &args[1];
let tmpdir = Path::new(&args[2]);
fn main() {}
"#;
- let args = std::os::args();
+ let args: Vec<String> = std::env::args().collect();
if args.len() < 4 {
panic!("expected rustc path");
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use std::{char, os};
+use std::{char, env};
use std::old_io::{File, Command};
use std::rand::{thread_rng, Rng};
}
fn main() {
- let args = os::args();
+ let args: Vec<String> = env::args().collect();
let rustc = &args[1];
let tmpdir = Path::new(&args[2]);
use std::old_io::{File, Command};
use std::iter::repeat;
use std::rand::{thread_rng, Rng};
-use std::{char, os};
+use std::{char, env};
// creates a file with `fn main() { <random ident> }` and checks the
// compiler emits a span of the appropriate length (for the
}
fn main() {
- let args = os::args();
+ let args: Vec<String> = env::args().collect();
let rustc = &args[1];
let tmpdir = Path::new(&args[2]);
let main_file = tmpdir.join("span_main.rs");
#![feature(unboxed_closures)]
#![feature(unsafe_destructor)]
-use std::os;
use std::env;
use std::old_io::process::Command;
use std::str;
}
fn main() {
- let args = os::args();
- let args = args;
+ let args: Vec<String> = env::args().collect();
if args.len() >= 2 && args[1] == "fail" {
foo();
} else if args.len() >= 2 && args[1] == "double-fail" {
// Test that cleanups for the RHS of shortcircuiting operators work.
-use std::os;
+use std::env;
pub fn main() {
- let args = os::args();
- let args = args;
+ let args: Vec<String> = env::args().collect();
// Here, the rvalue `"signal".to_string()` requires cleanup. Older versions
// of the code had a problem that the cleanup scope for this
// Make sure that if a process doesn't have its stdio/stderr descriptors set up
// that we don't die in a large ball of fire
-use std::os;
+use std::env;
use std::old_io::process;
pub fn main () {
- let args = os::args();
- let args = args;
+ let args: Vec<String> = env::args().collect();
if args.len() > 1 && args[1] == "child" {
for _ in 0..1000 {
println!("hello?");
// ignore-fast
-use std::os;
+use std::env;
use std::old_io;
use std::str;
fn main() {
- let args = os::args();
- let args = args;
+ let args: Vec<String> = env::args().collect();
if args.len() > 1 && args[1] == "child" {
child();
} else {
}
fn parent() {
- let args = os::args();
- let args = args;
+ let args: Vec<String> = env::args().collect();
let mut p = old_io::process::Command::new(&args[0])
.arg("child").spawn().unwrap();
p.stdin.as_mut().unwrap().write_str("test1\ntest2\ntest3").unwrap();
use std::old_io::process;
use std::old_io::Command;
use std::old_io;
-use std::os;
+use std::env;
fn main() {
- let args = os::args();
+ let args: Vec<String> = env::args().collect();
if args.len() > 1 && args[1] == "child" {
return child()
}
}
fn test() {
- let args = os::args();
+ let args: Vec<String> = env::args().collect();
let mut p = Command::new(&args[0]).arg("child")
.stdin(process::Ignored)
.stdout(process::Ignored)
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use std::os;
+use std::env;
use std::old_io::{stdio, Command};
fn main() {
- let args = os::args();
+ let mut args = env::args();
if args.len() > 1 {
let mut out = stdio::stdout();
out.write(&['a' as u8; 128 * 1024]).unwrap();
} else {
- let out = Command::new(&args[0]).arg("child").output();
+ let out = Command::new(&args.next().unwrap()).arg("child").output();
let out = out.unwrap();
assert!(out.status.success());
}
// except according to those terms.
use std::slice::SliceExt;
-use std::old_io::{Command, fs, USER_RWX};
-use std::os;
+use std::old_io::{fs, USER_RWX};
+use std::process;
use std::env;
use std::old_path::BytesContainer;
use std::rand::random;
fn main() {
// If we're the child, make sure we were invoked correctly
- let args = os::args();
+ let args: Vec<String> = env::args().collect();
if args.len() > 1 && args[1] == "child" {
// FIXME: This should check the whole `args[0]` instead of just
// checking that it ends_with the executable name. This
// is needed because of Windows, which has a different behavior.
// See #15149 for more info.
- return assert!(args[0].ends_with(&format!("mytest{}", os::consts::EXE_SUFFIX)[]));
+ return assert!(args[0].ends_with(&format!("mytest{}", env::consts::EXE_SUFFIX)[]));
}
test();
fn test() {
// If we're the parent, copy our own binary to a new directory.
- let my_path = os::self_exe_name().unwrap();
+ let my_path = env::current_exe().unwrap();
let my_dir = my_path.dir_path();
let random_u32: u32 = random();
fs::mkdir(&child_dir, USER_RWX).unwrap();
let child_path = child_dir.join(format!("mytest{}",
- os::consts::EXE_SUFFIX));
+ env::consts::EXE_SUFFIX));
fs::copy(&my_path, &child_path).unwrap();
// Append the new directory to our own PATH.
- let mut path = os::split_paths(env::var("PATH").ok().unwrap_or(String::new()));
- path.push(child_dir.clone());
- let path = os::join_paths(&path).unwrap();
+ let path = {
+ let mut paths: Vec<_> = env::split_paths(&env::var_os("PATH").unwrap()).collect();
+ paths.push(child_dir.clone());
+ env::join_paths(paths.iter()).unwrap()
+ };
- let child_output = Command::new("mytest").env("PATH", path)
- .arg("child")
- .output().unwrap();
+ let child_output = process::Command::new("mytest").env("PATH", &path)
+ .arg("child")
+ .output().unwrap();
assert!(child_output.status.success(),
format!("child assertion failed\n child stdout:\n {}\n child stderr:\n {}",
- child_output.output.container_as_str().unwrap(),
- child_output.error.container_as_str().unwrap()));
+ child_output.stdout.container_as_str().unwrap(),
+ child_output.stderr.container_as_str().unwrap()));
fs::rmdir_recursive(&child_dir).unwrap();
// except according to those terms.
use std::old_io::{process, Command};
-use std::os;
+use std::env;
fn main() {
- let len = os::args().len();
+ let len = env::args().len();
if len == 1 {
test();
}
fn test() {
- let status = Command::new(os::self_exe_name().unwrap())
+ let status = Command::new(env::current_exe().unwrap())
.arg("foo").arg("")
.stdout(process::InheritFd(1))
.stderr(process::InheritFd(2))
// ignore-windows currently windows requires UTF-8 for spawning processes
use std::old_io::Command;
-use std::os;
+use std::env;
fn main() {
- if os::args().len() == 1 {
- assert!(Command::new(os::self_exe_name().unwrap()).arg(b"\xff")
+ if env::args().len() == 1 {
+ assert!(Command::new(env::current_exe().unwrap()).arg(b"\xff")
.status().unwrap().success())
}
}
// except according to those terms.
fn parse_args() -> String {
- let args = ::std::os::args();
- let args = args;
+ let args: Vec<_> = ::std::env::args().collect();
let mut n = 0;
while n < args.len() {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use std::os;
+use std::env;
pub fn main() {
- for arg in &os::args() {
- match (*arg).clone() {
+ for arg in env::args() {
+ match arg.clone() {
_s => { }
}
}
extern crate log;
use std::old_io::Command;
-use std::os;
+use std::env;
use std::str;
fn main() {
- let args = os::args();
- let args = args;
+ let args: Vec<String> = env::args().collect();
if args.len() > 1 && args[1] == "child" {
debug!("foo");
debug!("bar");
#![feature(asm)]
use std::old_io::process::Command;
-use std::os;
+use std::env;
use std::thread::Thread;
// lifted from the test module
}
fn main() {
- let args = os::args();
- let args = args;
+ let args: Vec<String> = env::args().collect();
if args.len() > 1 && args[1] == "recurse" {
let _t = Thread::scoped(recurse);
} else {
#![feature(asm)]
use std::old_io::process::Command;
-use std::os;
+use std::env;
// lifted from the test module
// Inlining to avoid llvm turning the recursive functions into tail calls,
}
fn main() {
- let args = os::args();
+ let args: Vec<String> = env::args().collect();
if args.len() > 1 && args[1] == "recurse" {
recurse();
} else {
#![feature(asm)]
use std::old_io::process::Command;
-use std::os;
+use std::env;
// lifted from the test module
// Inlining to avoid llvm turning the recursive functions into tail calls,
}
fn main() {
- let args = os::args();
- let args = args;
+ let args: Vec<String> = env::args().collect();
if args.len() > 1 && args[1] == "silent" {
silent_recurse();
} else if args.len() > 1 && args[1] == "loud" {
use std::old_io::fs;
use std::old_io::Command;
use std::os;
+use std::env;
use std::old_path::Path;
fn main() {
- let my_args = os::args();
+ let my_args = env::args().collect::<Vec<_>>();
let my_cwd = os::getcwd().unwrap();
- let my_env = os::env();
+ let my_env = env::vars().collect::<Vec<_>>();
let my_path = Path::new(os::self_exe_name().unwrap());
let my_dir = my_path.dir_path();
let my_ext = my_path.extension_str().unwrap_or("");
// except according to those terms.
use std::old_io::process::Command;
-use std::os;
+use std::env;
fn main() {
- let args = os::args();
+ let args: Vec<String> = env::args().collect();
if args.len() > 1 && args[1] == "segfault" {
unsafe { *(0 as *mut int) = 1 }; // trigger a segfault
} else {
// ignore-windows
-use std::os;
+use std::env;
use std::old_io::process::{Command, ExitSignal, ExitStatus};
pub fn main() {
- let args = os::args();
- let args = args;
+ let args: Vec<String> = env::args().collect();
if args.len() >= 2 && args[1] == "signal" {
// Raise a segfault.
unsafe { *(0 as *mut int) = 0; }
// doesn't die in a ball of fire, but rather it's gracefully handled.
use std::os;
+use std::env;
use std::old_io::PipeStream;
use std::old_io::Command;
}
fn main() {
- let args = os::args();
- let args = args;
+ let args: Vec<String> = env::args().collect();
if args.len() > 1 && args[1] == "test" {
return test();
}