std: Stabilize the prelude module
This commit is an implementation of [RFC 503][rfc] which is a stabilization story for the prelude. Most of the RFC was directly applied, removing reexports. Some reexports are kept around, however: * `range` remains until range syntax has landed to reduce churn. * `Path` and `GenericPath` remain until path reform lands. This is done to prevent many imports of `GenericPath` which will soon be removed. * All `io` traits remain until I/O reform lands so imports can be rewritten all at once to `std::io::prelude::*`. This is a breaking change because many prelude reexports have been removed, and the RFC can be consulted for the exact list of removed reexports, as well as to find the locations of where to import them. [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0503-prelude-stabilization.md [breaking-change] Closes #20068
This commit is contained in:
parent
3dcc409fac
commit
c32d03f417
314 changed files with 1616 additions and 1155 deletions
|
|
@ -9,6 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
use std::task;
|
||||
use std::comm::{Receiver, channel};
|
||||
|
||||
pub fn foo<T:Send + Clone>(x: T) -> Receiver<T> {
|
||||
let (tx, rx) = channel();
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#![crate_type = "lib"]
|
||||
|
||||
use std::int;
|
||||
use std::str::from_str;
|
||||
|
||||
pub trait read {
|
||||
fn readMaybe(s: String) -> Option<Self>;
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
use std::cmp::PartialEq;
|
||||
use std::ops::{Add, Sub, Mul};
|
||||
|
||||
pub trait MyNum : Add<Self,Self> + Sub<Self,Self> + Mul<Self,Self> + PartialEq + Clone {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
#![feature(unboxed_closures)]
|
||||
|
||||
use std::ops::Add;
|
||||
|
||||
#[inline]
|
||||
pub fn has_closures() -> uint {
|
||||
let x = 1u;
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||
use std::os;
|
||||
use std::rand::{Rng, IsaacRng, SeedableRng};
|
||||
use std::str::from_str;
|
||||
use std::time::Duration;
|
||||
use std::uint;
|
||||
|
||||
|
|
|
|||
|
|
@ -15,11 +15,12 @@
|
|||
extern crate collections;
|
||||
extern crate rand;
|
||||
|
||||
use std::collections::BTreeSet;
|
||||
use std::collections::BitvSet;
|
||||
use std::collections::HashSet;
|
||||
use std::collections::BTreeSet;
|
||||
use std::hash::Hash;
|
||||
use std::os;
|
||||
use std::str::from_str;
|
||||
use std::time::Duration;
|
||||
use std::uint;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
use std::os;
|
||||
use std::str::from_str;
|
||||
use std::uint;
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -18,8 +18,10 @@
|
|||
// different scalability characteristics compared to the select
|
||||
// version.
|
||||
|
||||
use std::comm::{channel, Sender, Receiver};
|
||||
use std::comm;
|
||||
use std::os;
|
||||
use std::str::from_str;
|
||||
use std::thread::Thread;
|
||||
use std::time::Duration;
|
||||
use std::uint;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,9 @@
|
|||
//
|
||||
// I *think* it's the same, more or less.
|
||||
|
||||
use std::comm::{channel, Sender, Receiver};
|
||||
use std::os;
|
||||
use std::str::from_str;
|
||||
use std::thread::Thread;
|
||||
use std::time::Duration;
|
||||
use std::uint;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
// ignore-lexer-test FIXME #15679
|
||||
|
||||
use std::os;
|
||||
use std::str::from_str;
|
||||
use std::sync::{Arc, Future, Mutex, Condvar};
|
||||
use std::time::Duration;
|
||||
use std::uint;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,10 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::comm::channel;
|
||||
use std::os;
|
||||
use std::str::from_str;
|
||||
use std::thread::Thread;
|
||||
use std::uint;
|
||||
|
||||
// This is a simple bench that creates M pairs of tasks. These
|
||||
|
|
@ -34,21 +37,21 @@ fn ping_pong_bench(n: uint, m: uint) {
|
|||
// Create a stream B->A
|
||||
let (btx, brx) = channel::<()>();
|
||||
|
||||
spawn(move|| {
|
||||
Thread::spawn(move|| {
|
||||
let (tx, rx) = (atx, brx);
|
||||
for _ in range(0, n) {
|
||||
tx.send(());
|
||||
rx.recv();
|
||||
}
|
||||
});
|
||||
}).detach();
|
||||
|
||||
spawn(move|| {
|
||||
Thread::spawn(move|| {
|
||||
let (tx, rx) = (btx, arx);
|
||||
for _ in range(0, n) {
|
||||
rx.recv();
|
||||
tx.send(());
|
||||
}
|
||||
});
|
||||
}).detach();
|
||||
}
|
||||
|
||||
for _ in range(0, m) {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,10 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::comm::channel;
|
||||
use std::os;
|
||||
use std::str::from_str;
|
||||
use std::thread::Thread;
|
||||
use std::uint;
|
||||
|
||||
// A simple implementation of parfib. One subtree is found in a new
|
||||
|
|
@ -21,9 +24,9 @@ fn parfib(n: uint) -> uint {
|
|||
}
|
||||
|
||||
let (tx, rx) = channel();
|
||||
spawn(move|| {
|
||||
Thread::spawn(move|| {
|
||||
tx.send(parfib(n-1));
|
||||
});
|
||||
}).detach();
|
||||
let m2 = parfib(n-2);
|
||||
return (rx.recv() + m2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
use std::os;
|
||||
use std::str::from_str;
|
||||
|
||||
fn ack(m: int, n: int) -> int {
|
||||
if m == 0 {
|
||||
|
|
|
|||
|
|
@ -41,7 +41,9 @@
|
|||
extern crate arena;
|
||||
|
||||
use std::iter::range_step;
|
||||
use std::str::from_str;
|
||||
use std::sync::Future;
|
||||
|
||||
use arena::TypedArena;
|
||||
|
||||
enum Tree<'a> {
|
||||
|
|
|
|||
|
|
@ -41,8 +41,10 @@
|
|||
// no-pretty-expanded
|
||||
|
||||
use self::Color::{Red, Yellow, Blue};
|
||||
use std::string::String;
|
||||
use std::comm::{channel, Sender, Receiver};
|
||||
use std::fmt;
|
||||
use std::str::from_str;
|
||||
use std::thread::Thread;
|
||||
|
||||
fn print_complements() {
|
||||
let all = [Blue, Red, Yellow];
|
||||
|
|
@ -188,13 +190,13 @@ fn rendezvous(nn: uint, set: Vec<Color>) {
|
|||
let to_rendezvous = to_rendezvous.clone();
|
||||
let to_rendezvous_log = to_rendezvous_log.clone();
|
||||
let (to_creature, from_rendezvous) = channel();
|
||||
spawn(move|| {
|
||||
Thread::spawn(move|| {
|
||||
creature(ii,
|
||||
col,
|
||||
from_rendezvous,
|
||||
to_rendezvous,
|
||||
to_rendezvous_log);
|
||||
});
|
||||
}).detach();
|
||||
to_creature
|
||||
}).collect();
|
||||
|
||||
|
|
|
|||
|
|
@ -40,8 +40,9 @@
|
|||
|
||||
#![feature(slicing_syntax)]
|
||||
|
||||
use std::{cmp, iter, mem};
|
||||
use std::str::from_str;
|
||||
use std::sync::Future;
|
||||
use std::{cmp, iter, mem};
|
||||
|
||||
fn rotate(x: &mut [i32]) {
|
||||
let mut prev = x[0];
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ use std::cmp::min;
|
|||
use std::io::{stdout, IoResult};
|
||||
use std::os;
|
||||
use std::slice::bytes::copy_memory;
|
||||
use std::str::from_str;
|
||||
|
||||
const LINE_LEN: uint = 60;
|
||||
const LOOKUP_SIZE: uint = 4 * 1024;
|
||||
|
|
|
|||
|
|
@ -40,11 +40,12 @@
|
|||
|
||||
#![feature(slicing_syntax)]
|
||||
|
||||
use std::io;
|
||||
use std::io::{BufferedWriter, File};
|
||||
use std::cmp::min;
|
||||
use std::io::{BufferedWriter, File};
|
||||
use std::io;
|
||||
use std::num::Float;
|
||||
use std::os;
|
||||
use std::str::from_str;
|
||||
|
||||
const LINE_LENGTH: uint = 60;
|
||||
const IM: u32 = 139968;
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
use std::os;
|
||||
use std::str::from_str;
|
||||
|
||||
fn fib(n: int) -> int {
|
||||
if n < 2 {
|
||||
|
|
|
|||
|
|
@ -18,12 +18,15 @@
|
|||
extern crate collections;
|
||||
|
||||
use std::ascii::{AsciiExt, OwnedAsciiExt};
|
||||
use std::cmp::Ordering::{mod, Less, Greater, Equal};
|
||||
use std::collections::HashMap;
|
||||
use std::comm::{channel, Sender, Receiver};
|
||||
use std::mem::replace;
|
||||
use std::num::Float;
|
||||
use std::option;
|
||||
use std::os;
|
||||
use std::string::String;
|
||||
use std::string::IntoString;
|
||||
use std::thread::Thread;
|
||||
|
||||
fn f64_cmp(x: f64, y: f64) -> Ordering {
|
||||
// arbitrarily decide that NaNs are larger than everything.
|
||||
|
|
@ -167,9 +170,9 @@ fn main() {
|
|||
|
||||
let (to_child, from_parent) = channel();
|
||||
|
||||
spawn(move|| {
|
||||
Thread::spawn(move|| {
|
||||
make_sequence_processor(sz, &from_parent, &to_parent_);
|
||||
});
|
||||
}).detach();
|
||||
|
||||
to_child
|
||||
}).collect::<Vec<Sender<Vec<u8> >> >();
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@
|
|||
#![feature(slicing_syntax)]
|
||||
|
||||
use std::ascii::OwnedAsciiExt;
|
||||
use std::string::String;
|
||||
use std::slice;
|
||||
use std::sync::{Arc, Future};
|
||||
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@
|
|||
use std::io;
|
||||
use std::os;
|
||||
use std::simd::f64x2;
|
||||
use std::str::from_str;
|
||||
use std::sync::{Arc, Future};
|
||||
|
||||
const ITER: int = 50;
|
||||
|
|
|
|||
|
|
@ -40,7 +40,9 @@
|
|||
|
||||
// no-pretty-expanded FIXME #15189
|
||||
|
||||
use std::comm::channel;
|
||||
use std::sync::Arc;
|
||||
use std::thread::Thread;
|
||||
|
||||
//
|
||||
// Utilities.
|
||||
|
|
@ -310,11 +312,11 @@ fn par_search(masks: Vec<Vec<Vec<u64>>>) -> Data {
|
|||
let masks = masks.clone();
|
||||
let tx = tx.clone();
|
||||
let m = *m;
|
||||
spawn(move|| {
|
||||
Thread::spawn(move|| {
|
||||
let mut data = Data::new();
|
||||
search(&*masks, m, 1, List::Cons(m, &List::Nil), &mut data);
|
||||
tx.send(data);
|
||||
});
|
||||
}).detach();
|
||||
}
|
||||
|
||||
// collecting the results
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@
|
|||
// OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
use std::num::Float;
|
||||
use std::str::from_str;
|
||||
|
||||
const PI: f64 = 3.141592653589793;
|
||||
const SOLAR_MASS: f64 = 4.0 * PI * PI;
|
||||
|
|
|
|||
|
|
@ -20,8 +20,10 @@
|
|||
|
||||
extern crate getopts;
|
||||
|
||||
use std::comm::{channel, Sender};
|
||||
use std::os;
|
||||
use std::result::Result::{Ok, Err};
|
||||
use std::str::from_str;
|
||||
use std::thread::Thread;
|
||||
use std::time::Duration;
|
||||
|
||||
|
|
|
|||
|
|
@ -45,9 +45,10 @@
|
|||
extern crate libc;
|
||||
|
||||
use std::io::stdio::{stdin_raw, stdout_raw};
|
||||
use std::io::{IoResult, EndOfFile};
|
||||
use std::num::{div_rem};
|
||||
use std::ptr::{copy_memory, Unique};
|
||||
use std::io::{IoResult, EndOfFile};
|
||||
use std::thread::Thread;
|
||||
|
||||
struct Tables {
|
||||
table8: [u8;1 << 8],
|
||||
|
|
@ -229,26 +230,29 @@ unsafe impl<T: 'static> Send for Racy<T> {}
|
|||
fn parallel<'a, I, T, F>(mut iter: I, f: F)
|
||||
where T: 'a+Send + Sync,
|
||||
I: Iterator<&'a mut [T]>,
|
||||
F: Fn(&'a mut [T]) + Sync {
|
||||
F: Fn(&mut [T]) + Sync {
|
||||
use std::mem;
|
||||
use std::raw::Repr;
|
||||
|
||||
let (tx, rx) = channel();
|
||||
for chunk in iter {
|
||||
let tx = tx.clone();
|
||||
|
||||
iter.map(|chunk| {
|
||||
// Need to convert `f` and `chunk` to something that can cross the task
|
||||
// boundary.
|
||||
<<<<<<< HEAD
|
||||
let f = Racy(&f as *const F as *const uint);
|
||||
let raw = Racy(chunk.repr());
|
||||
spawn(move|| {
|
||||
let f = f.0 as *const F;
|
||||
unsafe { (*f)(mem::transmute(raw.0)) }
|
||||
drop(tx)
|
||||
=======
|
||||
let f = &f as *const F as *const uint;
|
||||
let raw = chunk.repr();
|
||||
Thread::spawn(move|| {
|
||||
let f = f as *const F;
|
||||
unsafe { (*f)(mem::transmute(raw)) }
|
||||
>>>>>>> std: Stabilize the prelude module
|
||||
});
|
||||
}
|
||||
drop(tx);
|
||||
for () in rx.iter() {}
|
||||
}).collect::<Vec<_>>();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -44,11 +44,13 @@
|
|||
#![feature(unboxed_closures)]
|
||||
|
||||
use std::iter::AdditiveIterator;
|
||||
use std::thread::Thread;
|
||||
use std::mem;
|
||||
use std::num::Float;
|
||||
use std::os;
|
||||
use std::raw::Repr;
|
||||
use std::simd::f64x2;
|
||||
use std::str::from_str;
|
||||
|
||||
fn main() {
|
||||
let args = os::args();
|
||||
|
|
@ -80,14 +82,15 @@ fn mult_AtAv(v: &[f64], out: &mut [f64], tmp: &mut [f64]) {
|
|||
}
|
||||
|
||||
fn mult_Av(v: &[f64], out: &mut [f64]) {
|
||||
parallel(out, |&: start, out| mult(v, out, start, |i, j| A(i, j)));
|
||||
parallel(out, |start, out| mult(v, out, start, |i, j| A(i, j)));
|
||||
}
|
||||
|
||||
fn mult_Atv(v: &[f64], out: &mut [f64]) {
|
||||
parallel(out, |&: start, out| mult(v, out, start, |i, j| A(j, i)));
|
||||
parallel(out, |start, out| mult(v, out, start, |i, j| A(j, i)));
|
||||
}
|
||||
|
||||
fn mult(v: &[f64], out: &mut [f64], start: uint, a: |uint, uint| -> f64) {
|
||||
fn mult<F>(v: &[f64], out: &mut [f64], start: uint, a: F)
|
||||
where F: Fn(uint, uint) -> f64 {
|
||||
for (i, slot) in out.iter_mut().enumerate().map(|(i, s)| (i + start, s)) {
|
||||
let mut sum = f64x2(0.0, 0.0);
|
||||
for (j, chunk) in v.chunks(2).enumerate().map(|(j, s)| (2 * j, s)) {
|
||||
|
|
@ -116,25 +119,20 @@ unsafe impl<T: 'static> Send for Racy<T> {}
|
|||
// Executes a closure in parallel over the given mutable slice. The closure `f`
|
||||
// is run in parallel and yielded the starting index within `v` as well as a
|
||||
// sub-slice of `v`.
|
||||
fn parallel<'a, T, F>(v: &'a mut [T], f: F)
|
||||
where T: Send + Sync,
|
||||
F: Fn(uint, &'a mut [T]) + Sync {
|
||||
let (tx, rx) = channel();
|
||||
fn parallel<T, F>(v: &mut [T], f: F)
|
||||
where T: Send + Sync,
|
||||
F: Fn(uint, &mut [T]) + Sync {
|
||||
let size = v.len() / os::num_cpus() + 1;
|
||||
|
||||
for (i, chunk) in v.chunks_mut(size).enumerate() {
|
||||
let tx = tx.clone();
|
||||
|
||||
v.chunks_mut(size).enumerate().map(|(i, chunk)| {
|
||||
// Need to convert `f` and `chunk` to something that can cross the task
|
||||
// boundary.
|
||||
let f = Racy(&f as *const _ as *const uint);
|
||||
let raw = Racy(chunk.repr());
|
||||
spawn(move|| {
|
||||
Thread::spawn(move|| {
|
||||
let f = f.0 as *const F;
|
||||
unsafe { (*f)(i * size, mem::transmute(raw.0)) }
|
||||
drop(tx)
|
||||
});
|
||||
}
|
||||
drop(tx);
|
||||
for () in rx.iter() {}
|
||||
})
|
||||
}).collect::<Vec<_>>();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,15 +38,19 @@
|
|||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
// OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
use std::comm::{channel, Sender, Receiver};
|
||||
use std::str::from_str;
|
||||
use std::thread::Thread;
|
||||
|
||||
fn start(n_tasks: int, token: int) {
|
||||
let (tx, mut rx) = channel();
|
||||
tx.send(token);
|
||||
for i in range(2, n_tasks + 1) {
|
||||
let (tx, next_rx) = channel();
|
||||
spawn(move|| roundtrip(i, tx, rx));
|
||||
Thread::spawn(move|| roundtrip(i, tx, rx)).detach();
|
||||
rx = next_rx;
|
||||
}
|
||||
spawn(move|| roundtrip(1, tx, rx));
|
||||
Thread::spawn(move|| roundtrip(1, tx, rx)).detach();
|
||||
}
|
||||
|
||||
fn roundtrip(id: int, tx: Sender<int>, rx: Receiver<int>) {
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// Useful for checking syscall usage of baseline scheduler usage
|
||||
fn main() {
|
||||
spawn(move|| {});
|
||||
}
|
||||
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
use std::collections::VecMap;
|
||||
use std::os;
|
||||
use std::str::from_str;
|
||||
use std::time::Duration;
|
||||
use std::uint;
|
||||
|
||||
|
|
|
|||
|
|
@ -12,11 +12,12 @@
|
|||
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use std::io;
|
||||
use std::io::stdio::StdReader;
|
||||
use std::io::BufferedReader;
|
||||
use std::io::stdio::StdReader;
|
||||
use std::io;
|
||||
use std::num::Int;
|
||||
use std::os;
|
||||
use std::str::from_str;
|
||||
|
||||
// Computes a single solution to a given 9x9 sudoku
|
||||
//
|
||||
|
|
|
|||
|
|
@ -17,16 +17,18 @@
|
|||
|
||||
// ignore-pretty very bad with line comments
|
||||
|
||||
use std::comm;
|
||||
use std::comm::{mod, channel};
|
||||
use std::os;
|
||||
use std::str::from_str;
|
||||
use std::task;
|
||||
use std::thread::Thread;
|
||||
use std::uint;
|
||||
|
||||
fn child_generation(gens_left: uint, tx: comm::Sender<()>) {
|
||||
// This used to be O(n^2) in the number of generations that ever existed.
|
||||
// With this code, only as many generations are alive at a time as tasks
|
||||
// alive at a time,
|
||||
spawn(move|| {
|
||||
Thread::spawn(move|| {
|
||||
if gens_left & 1 == 1 {
|
||||
task::deschedule(); // shake things up a bit
|
||||
}
|
||||
|
|
@ -35,7 +37,7 @@ fn child_generation(gens_left: uint, tx: comm::Sender<()>) {
|
|||
} else {
|
||||
tx.send(())
|
||||
}
|
||||
});
|
||||
}).detach();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
use std::os;
|
||||
use std::task;
|
||||
use std::uint;
|
||||
use std::str::from_str;
|
||||
|
||||
fn f(n: uint) {
|
||||
let mut i = 0u;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::comm::channel;
|
||||
|
||||
fn main() {
|
||||
let (tx, rx) = channel();
|
||||
let x = Some(rx);
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
// Test that binary operators consume their arguments
|
||||
|
||||
use std::ops::{Add, Sub, Mul, Div, Rem, BitAnd, BitXor, BitOr, Shl, Shr};
|
||||
|
||||
fn add<A: Add<B, ()>, B>(lhs: A, rhs: B) {
|
||||
lhs + rhs;
|
||||
drop(lhs); //~ ERROR use of moved value: `lhs`
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
// Test that move restrictions are enforced on overloaded binary operations
|
||||
|
||||
use std::ops::Add;
|
||||
|
||||
fn double_move<T: Add<T, ()>>(x: T) {
|
||||
x
|
||||
+
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::ops::Add;
|
||||
|
||||
#[deriving(Clone)]
|
||||
struct foo(Box<uint>);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::ops::Add;
|
||||
|
||||
#[deriving(Copy)]
|
||||
struct Point {
|
||||
x: int,
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::ops::Index;
|
||||
|
||||
struct MyVec<T> {
|
||||
data: Vec<T>,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@
|
|||
// Test that we still see borrowck errors of various kinds when using
|
||||
// indexing and autoderef in combination.
|
||||
|
||||
use std::ops::{Index, IndexMut};
|
||||
|
||||
struct Foo {
|
||||
x: int,
|
||||
y: int,
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::ops::{Index, IndexMut};
|
||||
|
||||
struct Foo {
|
||||
x: int,
|
||||
y: int,
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@
|
|||
// Tests (negatively) the ability for the Self type in default methods
|
||||
// to use capabilities granted by builtin kinds as supertraits.
|
||||
|
||||
use std::comm::{channel, Sender};
|
||||
|
||||
trait Foo : Sync+'static {
|
||||
fn foo(self, mut chan: Sender<Self>) { }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::comm::Receiver;
|
||||
|
||||
fn test<T: Sync>() {}
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::comm::Sender;
|
||||
|
||||
fn test<T: Sync>() {}
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -8,9 +8,12 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::comm::channel;
|
||||
use std::thread::Thread;
|
||||
|
||||
fn main() {
|
||||
let (tx, rx) = channel();
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| -> () {
|
||||
loop {
|
||||
let tx = tx;
|
||||
//~^ ERROR: use of moved value: `tx`
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@
|
|||
use std::ptr;
|
||||
use std::raw;
|
||||
|
||||
trait Slice {}
|
||||
|
||||
fn main() {
|
||||
unsafe {
|
||||
let nil: *const u8 = ptr::null();
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::ops::Deref;
|
||||
|
||||
struct MyPtr<'a>(&'a mut uint);
|
||||
impl<'a> Deref<uint> for MyPtr<'a> {
|
||||
fn deref<'b>(&'b self) -> &'b uint { self.0 }
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::num::ToPrimitive;
|
||||
|
||||
trait Add {
|
||||
fn to_int(&self) -> int;
|
||||
fn add_dynamic(&self, other: &Add) -> int;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
// Test that move restrictions are enforced on overloaded unary operations
|
||||
|
||||
use std::ops::Not;
|
||||
|
||||
fn move_then_borrow<T: Not<T> + Clone>(x: T) {
|
||||
!x;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::comm::channel;
|
||||
|
||||
// Test that a class with an unsendable field can't be
|
||||
// sent
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
// (In this case the mul method should take &f64 and not f64)
|
||||
// See: #11450
|
||||
|
||||
use std::ops::Mul;
|
||||
|
||||
struct Vec1 {
|
||||
x: f64
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#[phase(plugin, link)]
|
||||
extern crate "std" as std;
|
||||
#[prelude_import]
|
||||
use std::prelude::*;
|
||||
use std::prelude::v1::*;
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@
|
|||
|
||||
// Basic boolean tests
|
||||
|
||||
use std::cmp::{Equal, Greater, Less};
|
||||
use std::ops::{BitAnd, BitOr, BitXor};
|
||||
|
||||
fn main() {
|
||||
assert_eq!(false.eq(&true), false);
|
||||
assert_eq!(false == false, true);
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@
|
|||
// a Send. Basically this just makes sure rustc is using
|
||||
// each_bound_trait_and_supertraits in type_contents correctly.
|
||||
|
||||
use std::comm::{channel, Sender};
|
||||
|
||||
trait Bar : Send { }
|
||||
trait Foo : Bar { }
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@
|
|||
// even when using them cross-crate.
|
||||
|
||||
extern crate trait_superkinds_in_metadata;
|
||||
|
||||
use std::comm::{channel, Sender, Receiver};
|
||||
use trait_superkinds_in_metadata::{RequiresRequiresShareAndSend, RequiresShare};
|
||||
|
||||
#[deriving(PartialEq)]
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@
|
|||
// builtin-kinds, e.g., if a trait requires Send to implement, then
|
||||
// at usage site of that trait, we know we have the Send capability.
|
||||
|
||||
use std::comm::{channel, Sender, Receiver};
|
||||
|
||||
trait Foo : Send { }
|
||||
|
||||
impl <T: Send> Foo for T { }
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@
|
|||
// Tests the ability for the Self type in default methods to use
|
||||
// capabilities granted by builtin kinds as supertraits.
|
||||
|
||||
use std::comm::{Sender, channel};
|
||||
|
||||
trait Foo : Send {
|
||||
fn foo(self, tx: Sender<Self>) {
|
||||
tx.send(self);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
extern crate libc;
|
||||
|
||||
use std::c_str::ToCStr;
|
||||
|
||||
mod mlibc {
|
||||
use libc::{c_char, c_long, c_longlong};
|
||||
|
||||
|
|
|
|||
|
|
@ -17,8 +17,10 @@
|
|||
extern crate log;
|
||||
|
||||
use log::{set_logger, Logger, LogRecord};
|
||||
use std::comm::channel;
|
||||
use std::fmt;
|
||||
use std::io::{ChanReader, ChanWriter};
|
||||
use std::thread::Thread;
|
||||
|
||||
struct MyWriter(ChanWriter);
|
||||
|
||||
|
|
@ -32,7 +34,7 @@ impl Logger for MyWriter {
|
|||
fn main() {
|
||||
let (tx, rx) = channel();
|
||||
let (mut r, w) = (ChanReader::new(rx), ChanWriter::new(tx));
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
set_logger(box MyWriter(w) as Box<Logger+Send>);
|
||||
debug!("debug");
|
||||
info!("info");
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#![feature(unboxed_closures)]
|
||||
|
||||
use std::comm;
|
||||
use std::comm::channel;
|
||||
|
||||
fn foo<F:FnOnce()+Send>(blk: F) {
|
||||
blk();
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::cmp::Ordering;
|
||||
|
||||
// Test default methods in PartialOrd and PartialEq
|
||||
//
|
||||
struct Fool(bool);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
use std::task;
|
||||
use std::comm::{channel, Sender};
|
||||
|
||||
pub fn main() {
|
||||
let (tx, rx) = channel();
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
use std::{str, string};
|
||||
use std::c_str::ToCStr;
|
||||
|
||||
const A: [u8; 2] = ['h' as u8, 'i' as u8];
|
||||
const B: &'static [u8; 2] = &A;
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ extern crate libc;
|
|||
use std::io::{Process, Command, timer};
|
||||
use std::time::Duration;
|
||||
use std::str;
|
||||
use std::comm::channel;
|
||||
use std::thread::Thread;
|
||||
|
||||
macro_rules! succeed( ($e:expr) => (
|
||||
match $e { Ok(..) => {}, Err(e) => panic!("panic: {}", e) }
|
||||
|
|
@ -84,12 +86,12 @@ pub fn test_destroy_actually_kills(force: bool) {
|
|||
let (tx, rx1) = channel();
|
||||
let mut t = timer::Timer::new().unwrap();
|
||||
let rx2 = t.oneshot(Duration::milliseconds(1000));
|
||||
spawn(move|| {
|
||||
Thread::spawn(move|| {
|
||||
select! {
|
||||
() = rx2.recv() => unsafe { libc::exit(1) },
|
||||
() = rx1.recv() => {}
|
||||
}
|
||||
});
|
||||
}).detach();
|
||||
match p.wait().unwrap() {
|
||||
ExitStatus(..) => panic!("expected a signal"),
|
||||
ExitSignal(..) => tx.send(()),
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
// Test that `&mut T` implements `DerefMut<T>`
|
||||
|
||||
use std::ops::DerefMut;
|
||||
|
||||
fn inc<T:DerefMut<int>>(mut t: T) {
|
||||
*t += 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
// Test that `&T` and `&mut T` implement `Deref<T>`
|
||||
|
||||
use std::ops::Deref;
|
||||
|
||||
fn deref<U:Copy,T:Deref<U>>(t: T) -> U {
|
||||
*t
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@
|
|||
// where possible, by having a type that panics when compared as the
|
||||
// second element, so this passes iff the instances shortcircuit.
|
||||
|
||||
use std::cmp::Ordering;
|
||||
|
||||
pub struct FailCmp;
|
||||
impl PartialEq for FailCmp {
|
||||
fn eq(&self, _: &FailCmp) -> bool { panic!("eq") }
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
|
||||
use std::ops::Add;
|
||||
use std::num::Zero;
|
||||
|
||||
#[deriving(Zero)]
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
use std::task;
|
||||
use std::comm::{channel, Sender};
|
||||
|
||||
#[deriving(PartialEq, Show)]
|
||||
enum Message {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
// Test that a custom deref with a fat pointer return type does not ICE
|
||||
|
||||
use std::ops::{Deref, DerefMut};
|
||||
|
||||
pub struct Arr {
|
||||
ptr: Box<[uint]>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
// Test that a custom deref with a fat pointer return type does not ICE
|
||||
|
||||
use std::ops::Deref;
|
||||
|
||||
pub struct Arr {
|
||||
ptr: Box<[uint]>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::ops::{Deref, DerefMut};
|
||||
|
||||
// Generic unique/owned smaht pointer.
|
||||
struct Own<T> {
|
||||
value: *mut T
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@
|
|||
// ignore-fast doesn't like extern crate
|
||||
|
||||
extern crate libc;
|
||||
use std::c_str::ToCStr;
|
||||
|
||||
mod mlibc {
|
||||
extern crate libc;
|
||||
use self::libc::{c_char, size_t};
|
||||
use libc::{c_char, size_t};
|
||||
|
||||
extern {
|
||||
#[link_name = "strlen"]
|
||||
|
|
|
|||
|
|
@ -9,9 +9,6 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
|
||||
extern crate collections;
|
||||
|
||||
/**
|
||||
A somewhat reduced test case to expose some Valgrind issues.
|
||||
|
||||
|
|
@ -24,6 +21,7 @@ pub fn map(filename: String, emit: map_reduce::putter) {
|
|||
|
||||
mod map_reduce {
|
||||
use std::collections::HashMap;
|
||||
use std::comm::{channel, Sender};
|
||||
use std::str;
|
||||
use std::task;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::ops::Deref;
|
||||
|
||||
struct Root {
|
||||
jsref: JSRef
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,9 @@
|
|||
// This test may not always fail, but it can be flaky if the race it used to
|
||||
// expose is still present.
|
||||
|
||||
use std::comm::{channel, Sender, Receiver};
|
||||
use std::thread::Thread;
|
||||
|
||||
fn helper(rx: Receiver<Sender<()>>) {
|
||||
for tx in rx.iter() {
|
||||
let _ = tx.send_opt(());
|
||||
|
|
@ -19,7 +22,7 @@ fn helper(rx: Receiver<Sender<()>>) {
|
|||
|
||||
fn main() {
|
||||
let (tx, rx) = channel();
|
||||
spawn(move|| { helper(rx) });
|
||||
let _t = Thread::spawn(move|| { helper(rx) }).detach();
|
||||
let (snd, rcv) = channel::<int>();
|
||||
for _ in range(1i, 100000i) {
|
||||
snd.send(1i);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::ops::Index;
|
||||
|
||||
struct Mat<T> { data: Vec<T>, cols: uint, }
|
||||
|
||||
impl<T> Mat<T> {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#![feature(unboxed_closures)]
|
||||
|
||||
use std::thread::Thread;
|
||||
use std::mem;
|
||||
|
||||
fn main() {
|
||||
|
|
@ -19,7 +20,7 @@ fn main() {
|
|||
// Check that both closures are capturing by value
|
||||
assert_eq!(1, mem::size_of_val(&closure));
|
||||
|
||||
spawn(move|| {
|
||||
Thread::spawn(move|| {
|
||||
let ok = closure;
|
||||
})
|
||||
}).join().ok().unwrap();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
#![feature(unboxed_closures)]
|
||||
|
||||
use std::ops::{Deref, DerefMut};
|
||||
|
||||
struct X(Box<int>);
|
||||
|
||||
static mut DESTRUCTOR_RAN: bool = false;
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#![feature(default_type_params)]
|
||||
|
||||
use std::task;
|
||||
use std::comm::Sender;
|
||||
use std::thunk::Invoke;
|
||||
|
||||
type RingBuffer = Vec<f64> ;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::ops::Mul;
|
||||
|
||||
struct Vec2 {
|
||||
x: f64,
|
||||
y: f64
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::ops::Add;
|
||||
|
||||
trait Positioned<S> {
|
||||
fn SetX(&mut self, S);
|
||||
fn X(&self) -> S;
|
||||
|
|
|
|||
|
|
@ -9,13 +9,15 @@
|
|||
// except according to those terms.
|
||||
|
||||
use std::io::println;
|
||||
use std::comm::channel;
|
||||
use std::thread::Thread;
|
||||
|
||||
pub fn main() {
|
||||
let (tx, rx) = channel();
|
||||
|
||||
tx.send("hello, world");
|
||||
|
||||
spawn(move|| {
|
||||
Thread::spawn(move|| {
|
||||
println(rx.recv());
|
||||
});
|
||||
}).join().ok().unwrap();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
use std::task;
|
||||
use std::comm::channel;
|
||||
|
||||
pub fn main() {
|
||||
let (tx, rx) = channel::<&'static str>();
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
#![feature(advanced_slice_patterns)]
|
||||
|
||||
use std::ops::Add;
|
||||
|
||||
fn foo<T: Add<T, T> + Clone>([x, y, z]: [T; 3]) -> (T, T, T) {
|
||||
(x.clone(), x.clone() + y.clone(), x + y + z)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,9 +8,12 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::thread::Thread;
|
||||
use std::comm::{channel, Receiver};
|
||||
|
||||
fn periodical(n: int) -> Receiver<bool> {
|
||||
let (chan, port) = channel();
|
||||
spawn(move|| {
|
||||
Thread::spawn(move|| {
|
||||
loop {
|
||||
for _ in range(1, n) {
|
||||
match chan.send_opt(false) {
|
||||
|
|
@ -23,13 +26,13 @@ fn periodical(n: int) -> Receiver<bool> {
|
|||
Err(..) => break
|
||||
}
|
||||
}
|
||||
});
|
||||
}).detach();
|
||||
return port;
|
||||
}
|
||||
|
||||
fn integers() -> Receiver<int> {
|
||||
let (chan, port) = channel();
|
||||
spawn(move|| {
|
||||
Thread::spawn(move|| {
|
||||
let mut i = 1;
|
||||
loop {
|
||||
match chan.send_opt(i) {
|
||||
|
|
@ -38,7 +41,7 @@ fn integers() -> Receiver<int> {
|
|||
}
|
||||
i = i + 1;
|
||||
}
|
||||
});
|
||||
}).detach();
|
||||
return port;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,13 +8,14 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::comm;
|
||||
use std::comm::{mod, channel};
|
||||
use std::io::timer::Timer;
|
||||
use std::thread::Thread;
|
||||
use std::time::Duration;
|
||||
|
||||
pub fn main() {
|
||||
let (tx, rx) = channel();
|
||||
spawn(move||{
|
||||
let _t = Thread::spawn(move||{
|
||||
let mut timer = Timer::new().unwrap();
|
||||
timer.sleep(Duration::milliseconds(10));
|
||||
tx.send(());
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
use std::task;
|
||||
use std::comm::{channel, Sender};
|
||||
|
||||
fn producer(tx: &Sender<Vec<u8>>) {
|
||||
tx.send(
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
use std::cell::Cell;
|
||||
use std::fmt;
|
||||
use std::thread::Thread;
|
||||
|
||||
struct Foo(Cell<int>);
|
||||
|
||||
|
|
@ -26,13 +27,10 @@ impl fmt::Show for Foo {
|
|||
}
|
||||
|
||||
pub fn main() {
|
||||
let (tx, rx) = channel();
|
||||
spawn(move|| {
|
||||
Thread::spawn(move|| {
|
||||
let mut f = Foo(Cell::new(0));
|
||||
println!("{}", f);
|
||||
let Foo(ref mut f) = f;
|
||||
assert!(f.get() == 1);
|
||||
tx.send(());
|
||||
});
|
||||
rx.recv();
|
||||
}).join().ok().unwrap();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,11 +10,13 @@
|
|||
|
||||
#![feature(macro_rules)]
|
||||
|
||||
use std::thread::Thread;
|
||||
|
||||
macro_rules! expr (($e: expr) => { $e });
|
||||
|
||||
macro_rules! spawn {
|
||||
($($code: tt)*) => {
|
||||
expr!(spawn(move|| {$($code)*}))
|
||||
expr!(Thread::spawn(move|| {$($code)*}).detach())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
use std::uint;
|
||||
use std::str::from_str;
|
||||
|
||||
pub fn main() {
|
||||
// sometimes we have had trouble finding
|
||||
|
|
|
|||
|
|
@ -15,6 +15,9 @@
|
|||
// necessary. Testing the methods of the impls is done within the source
|
||||
// file for each numeric type.
|
||||
|
||||
use std::ops::Add;
|
||||
use std::num::ToPrimitive;
|
||||
|
||||
pub fn main() {
|
||||
// ints
|
||||
// num
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
use std::io::process::Command;
|
||||
use std::os;
|
||||
use std::thread::Thread;
|
||||
|
||||
// lifted from the test module
|
||||
// Inlining to avoid llvm turning the recursive functions into tail calls,
|
||||
|
|
@ -36,12 +37,7 @@ fn main() {
|
|||
let args = os::args();
|
||||
let args = args.as_slice();
|
||||
if args.len() > 1 && args[1].as_slice() == "recurse" {
|
||||
let (tx, rx) = channel();
|
||||
spawn(move|| {
|
||||
recurse();
|
||||
tx.send(());
|
||||
});
|
||||
rx.recv();
|
||||
let _t = Thread::spawn(recurse);
|
||||
} else {
|
||||
let recurse = Command::new(args[0].as_slice()).arg("recurse").output().unwrap();
|
||||
assert!(!recurse.status.success());
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::ops::Deref;
|
||||
|
||||
struct DerefArray<'a, T:'a> {
|
||||
inner: &'a [T]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
use std::rc::Rc;
|
||||
use std::ops::Deref;
|
||||
|
||||
struct DerefWrapper<X, Y> {
|
||||
x: X,
|
||||
|
|
@ -30,6 +31,8 @@ impl<X, Y> Deref<Y> for DerefWrapper<X, Y> {
|
|||
}
|
||||
|
||||
mod priv_test {
|
||||
use std::ops::Deref;
|
||||
|
||||
pub struct DerefWrapperHideX<X, Y> {
|
||||
x: X,
|
||||
pub y: Y
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
use std::string::String;
|
||||
use std::num::ToPrimitive;
|
||||
|
||||
#[deriving(PartialEq, Show)]
|
||||
struct Point {
|
||||
|
|
@ -31,7 +31,6 @@ pub fn main() {
|
|||
assert_eq!((i_value, *i.borrow()), (2, 5));
|
||||
|
||||
let s = Rc::new("foo".to_string());
|
||||
assert!(s.equiv(&("foo")));
|
||||
assert_eq!(s.as_slice(), "foo");
|
||||
|
||||
let mut_s = Rc::new(RefCell::new(String::from_str("foo")));
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#![feature(unboxed_closures)]
|
||||
|
||||
use std::ops::Fn;
|
||||
use std::ops::Add;
|
||||
|
||||
struct G;
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
// Test overloaded indexing combined with autoderef.
|
||||
|
||||
use std::ops::{Index, IndexMut};
|
||||
|
||||
struct Foo {
|
||||
x: int,
|
||||
y: int,
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@
|
|||
// Test using overloaded indexing when the "map" is stored in a
|
||||
// field. This caused problems at some point.
|
||||
|
||||
use std::ops::Index;
|
||||
|
||||
struct Foo {
|
||||
x: int,
|
||||
y: int,
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::ops::{Index, IndexMut};
|
||||
|
||||
struct Foo {
|
||||
x: int,
|
||||
y: int,
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue