auto merge of #7334 : thestinger/rust/old_iter, r=Aatch
the `test/run-pass/class-trait-bounded-param.rs` test was xfailed and written in an ancient dialect of Rust so I've just removed it this also removes `to_vec` from DList because it's provided by `std::iter::to_vec` an Iterator implementation is added for OptVec but some transitional internal iterator methods are still left
This commit is contained in:
commit
dfb7de8e0e
src
libextra
librustc
libstd
libsyntax
test
run-fail
run-pass
autoderef-method-priority.rsclass-cast-to-trait-cross-crate.rsclass-impl-parameterized-trait.rsclass-impl-very-parameterized-trait.rsclass-implements-multiple-traits.rsclass-trait-bounded-param.rscoerce-reborrow-imm-vec-arg.rscoerce-reborrow-imm-vec-rcvr.rsderiving-global.rsderiving-meta-empty-trait-list.rsextern-mod-url.rsfn-bare-size.rsforeign-mod.rcissue-1866.rsissue-2101.rsissue-2190-2.rsissue-3290.rsissue-3796.rsissue-3874.rsissue-3979-2.rsissue-3979-generics.rsissue-4241.rsissue-4541.rsissue-4542.rsissue_3882.rslabeled-break.rsmatch-borrowed_str.rspipe-select-macro.rspreempt.rsrcvr-borrowed-to-region.rsregions-borrow-evec-at.rsresolve-issue-2428.rstag-align-dyn-variants.rstag-align-u64.rstrait-cast.rstraits.rsunconstrained-region.rs
@ -666,12 +666,8 @@ impl BitvSet {
|
||||
pub fn symmetric_difference_with(&mut self, other: &BitvSet) {
|
||||
self.other_op(other, |w1, w2| w1 ^ w2);
|
||||
}
|
||||
}
|
||||
|
||||
impl BaseIter<uint> for BitvSet {
|
||||
fn size_hint(&self) -> Option<uint> { Some(self.len()) }
|
||||
|
||||
fn each(&self, blk: &fn(v: &uint) -> bool) -> bool {
|
||||
pub fn each(&self, blk: &fn(v: &uint) -> bool) -> bool {
|
||||
for self.bitv.storage.iter().enumerate().advance |(i, &w)| {
|
||||
if !iterate_bits(i * uint::bits, w, |b| blk(&b)) {
|
||||
return false;
|
||||
|
@ -21,8 +21,6 @@ Do not use ==, !=, <, etc on doubly-linked lists -- it may not terminate.
|
||||
use core::prelude::*;
|
||||
|
||||
use core::managed;
|
||||
use core::old_iter;
|
||||
use core::vec;
|
||||
|
||||
pub type DListLink<T> = Option<@mut DListNode<T>>;
|
||||
|
||||
@ -213,6 +211,42 @@ impl<T> DList<T> {
|
||||
}
|
||||
|
||||
impl<T> DList<T> {
|
||||
/**
|
||||
* Iterates through the current contents.
|
||||
*
|
||||
* Attempts to access this dlist during iteration are allowed (to
|
||||
* allow for e.g. breadth-first search with in-place enqueues), but
|
||||
* removing the current node is forbidden.
|
||||
*/
|
||||
pub fn each(@mut self, f: &fn(v: &T) -> bool) -> bool {
|
||||
let mut link = self.peek_n();
|
||||
while link.is_some() {
|
||||
let nobe = link.get();
|
||||
assert!(nobe.linked);
|
||||
|
||||
{
|
||||
let frozen_nobe = &*nobe;
|
||||
if !f(&frozen_nobe.data) { return false; }
|
||||
}
|
||||
|
||||
// Check (weakly) that the user didn't do a remove.
|
||||
if self.size == 0 {
|
||||
fail!("The dlist became empty during iteration??")
|
||||
}
|
||||
if !nobe.linked ||
|
||||
(!((nobe.prev.is_some()
|
||||
|| managed::mut_ptr_eq(self.hd.expect("headless dlist?"),
|
||||
nobe))
|
||||
&& (nobe.next.is_some()
|
||||
|| managed::mut_ptr_eq(self.tl.expect("tailless dlist?"),
|
||||
nobe)))) {
|
||||
fail!("Removing a dlist node during iteration is forbidden!")
|
||||
}
|
||||
link = nobe.next_link();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Get the size of the list. O(1).
|
||||
pub fn len(@mut self) -> uint { self.size }
|
||||
/// Returns true if the list is empty. O(1).
|
||||
@ -484,56 +518,6 @@ impl<T:Copy> DList<T> {
|
||||
|
||||
/// Get data at the list's tail, failing if empty. O(1).
|
||||
pub fn tail(@mut self) -> T { copy self.tail_n().data }
|
||||
|
||||
/// Get the elements of the list as a vector. O(n).
|
||||
pub fn to_vec(@mut self) -> ~[T] {
|
||||
let mut v = vec::with_capacity(self.size);
|
||||
for old_iter::eachi(&self) |index,data| {
|
||||
v[index] = copy *data;
|
||||
}
|
||||
v
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> BaseIter<T> for @mut DList<T> {
|
||||
/**
|
||||
* Iterates through the current contents.
|
||||
*
|
||||
* Attempts to access this dlist during iteration are allowed (to
|
||||
* allow for e.g. breadth-first search with in-place enqueues), but
|
||||
* removing the current node is forbidden.
|
||||
*/
|
||||
fn each(&self, f: &fn(v: &T) -> bool) -> bool {
|
||||
let mut link = self.peek_n();
|
||||
while link.is_some() {
|
||||
let nobe = link.get();
|
||||
assert!(nobe.linked);
|
||||
|
||||
{
|
||||
let frozen_nobe = &*nobe;
|
||||
if !f(&frozen_nobe.data) { return false; }
|
||||
}
|
||||
|
||||
// Check (weakly) that the user didn't do a remove.
|
||||
if self.size == 0 {
|
||||
fail!("The dlist became empty during iteration??")
|
||||
}
|
||||
if !nobe.linked ||
|
||||
(!((nobe.prev.is_some()
|
||||
|| managed::mut_ptr_eq(self.hd.expect("headless dlist?"),
|
||||
nobe))
|
||||
&& (nobe.next.is_some()
|
||||
|| managed::mut_ptr_eq(self.tl.expect("tailless dlist?"),
|
||||
nobe)))) {
|
||||
fail!("Removing a dlist node during iteration is forbidden!")
|
||||
}
|
||||
link = nobe.next_link();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn size_hint(&self) -> Option<uint> { Some(self.len()) }
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@ -542,7 +526,6 @@ mod tests {
|
||||
|
||||
use super::*;
|
||||
|
||||
use core::old_iter;
|
||||
use core::vec;
|
||||
|
||||
#[test]
|
||||
@ -759,11 +742,6 @@ mod tests {
|
||||
assert_eq!(l.len(), 3);
|
||||
}
|
||||
#[test]
|
||||
fn test_dlist_foldl() {
|
||||
let l = from_vec(vec::from_fn(101, |x|x));
|
||||
assert_eq!(old_iter::foldl(&l, 0, |accum,elem| *accum+*elem), 5050);
|
||||
}
|
||||
#[test]
|
||||
fn test_dlist_break_early() {
|
||||
let l = from_vec([1,2,3,4,5]);
|
||||
let mut x = 0;
|
||||
|
@ -14,25 +14,15 @@
|
||||
|
||||
use core::prelude::*;
|
||||
|
||||
use core::old_iter::BaseIter;
|
||||
use core::unstable::intrinsics::{move_val_init, init};
|
||||
use core::util::{replace, swap};
|
||||
use core::vec;
|
||||
|
||||
#[allow(missing_doc)]
|
||||
/// A priority queue implemented with a binary heap
|
||||
pub struct PriorityQueue<T> {
|
||||
priv data: ~[T],
|
||||
}
|
||||
|
||||
impl<T:Ord> BaseIter<T> for PriorityQueue<T> {
|
||||
/// Visit all values in the underlying vector.
|
||||
///
|
||||
/// The values are **not** visited in order.
|
||||
fn each(&self, f: &fn(&T) -> bool) -> bool { self.data.iter().advance(f) }
|
||||
|
||||
fn size_hint(&self) -> Option<uint> { Some(self.data.len()) }
|
||||
}
|
||||
|
||||
impl<T:Ord> Container for PriorityQueue<T> {
|
||||
/// Returns the length of the queue
|
||||
fn len(&self) -> uint { self.data.len() }
|
||||
@ -47,6 +37,11 @@ impl<T:Ord> Mutable for PriorityQueue<T> {
|
||||
}
|
||||
|
||||
impl<T:Ord> PriorityQueue<T> {
|
||||
/// Visit all values in the underlying vector.
|
||||
///
|
||||
/// The values are **not** visited in order.
|
||||
pub fn each(&self, f: &fn(&T) -> bool) -> bool { self.data.iter().advance(f) }
|
||||
|
||||
/// Returns the greatest item in the queue - fails if empty
|
||||
pub fn top<'a>(&'a self) -> &'a T { &self.data[0] }
|
||||
|
||||
|
@ -19,8 +19,6 @@ use core::prelude::*;
|
||||
|
||||
use core::cmp;
|
||||
use core::container::{Container, Mutable, Map, Set};
|
||||
use core::old_iter::BaseIter;
|
||||
use core::old_iter;
|
||||
use core::uint;
|
||||
use core::util::replace;
|
||||
use core::vec;
|
||||
@ -212,12 +210,6 @@ impl Mutable for SmallIntSet {
|
||||
fn clear(&mut self) { self.map.clear() }
|
||||
}
|
||||
|
||||
impl BaseIter<uint> for SmallIntSet {
|
||||
/// Visit all values in order
|
||||
fn each(&self, f: &fn(&uint) -> bool) -> bool { self.map.each_key(f) }
|
||||
fn size_hint(&self) -> Option<uint> { Some(self.len()) }
|
||||
}
|
||||
|
||||
impl Set<uint> for SmallIntSet {
|
||||
/// Return true if the set contains a value
|
||||
fn contains(&self, value: &uint) -> bool { self.map.contains_key(value) }
|
||||
@ -233,12 +225,14 @@ impl Set<uint> for SmallIntSet {
|
||||
/// Return true if the set has no elements in common with `other`.
|
||||
/// This is equivalent to checking for an empty uintersection.
|
||||
fn is_disjoint(&self, other: &SmallIntSet) -> bool {
|
||||
old_iter::all(self, |v| !other.contains(v))
|
||||
for self.each |v| { if other.contains(v) { return false } }
|
||||
true
|
||||
}
|
||||
|
||||
/// Return true if the set is a subset of another
|
||||
fn is_subset(&self, other: &SmallIntSet) -> bool {
|
||||
old_iter::all(self, |v| other.contains(v))
|
||||
for self.each |v| { if !other.contains(v) { return false } }
|
||||
true
|
||||
}
|
||||
|
||||
/// Return true if the set is a superset of another
|
||||
@ -286,6 +280,9 @@ impl Set<uint> for SmallIntSet {
|
||||
impl SmallIntSet {
|
||||
/// Create an empty SmallIntSet
|
||||
pub fn new() -> SmallIntSet { SmallIntSet{map: SmallIntMap::new()} }
|
||||
|
||||
/// Visit all values in order
|
||||
pub fn each(&self, f: &fn(&uint) -> bool) -> bool { self.map.each_key(f) }
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -249,22 +249,6 @@ pub struct TreeSet<T> {
|
||||
priv map: TreeMap<T, ()>
|
||||
}
|
||||
|
||||
impl<T: TotalOrd> BaseIter<T> for TreeSet<T> {
|
||||
/// Visit all values in order
|
||||
#[inline]
|
||||
fn each(&self, f: &fn(&T) -> bool) -> bool { self.map.each_key(f) }
|
||||
#[inline]
|
||||
fn size_hint(&self) -> Option<uint> { Some(self.len()) }
|
||||
}
|
||||
|
||||
impl<T: TotalOrd> ReverseIter<T> for TreeSet<T> {
|
||||
/// Visit all values in reverse order
|
||||
#[inline]
|
||||
fn each_reverse(&self, f: &fn(&T) -> bool) -> bool {
|
||||
self.map.each_key_reverse(f)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Eq + TotalOrd> Eq for TreeSet<T> {
|
||||
#[inline]
|
||||
fn eq(&self, other: &TreeSet<T>) -> bool { self.map == other.map }
|
||||
@ -499,6 +483,16 @@ impl<T: TotalOrd> TreeSet<T> {
|
||||
pub fn iter<'a>(&'a self) -> TreeSetIterator<'a, T> {
|
||||
TreeSetIterator{iter: self.map.iter()}
|
||||
}
|
||||
|
||||
/// Visit all values in order
|
||||
#[inline]
|
||||
pub fn each(&self, f: &fn(&T) -> bool) -> bool { self.map.each_key(f) }
|
||||
|
||||
/// Visit all values in reverse order
|
||||
#[inline]
|
||||
pub fn each_reverse(&self, f: &fn(&T) -> bool) -> bool {
|
||||
self.map.each_key_reverse(f)
|
||||
}
|
||||
}
|
||||
|
||||
/// Lazy forward iterator over a set
|
||||
|
@ -731,8 +731,8 @@ fn encode_info_for_method(ecx: &EncodeContext,
|
||||
}
|
||||
|
||||
let mut combined_ty_params = opt_vec::Empty;
|
||||
combined_ty_params.push_all(&owner_generics.ty_params);
|
||||
combined_ty_params.push_all(&method_generics.ty_params);
|
||||
for owner_generics.ty_params.each |x| { combined_ty_params.push(copy *x) }
|
||||
for method_generics.ty_params.each |x| { combined_ty_params.push(copy *x) }
|
||||
let len = combined_ty_params.len();
|
||||
encode_type_param_bounds(ebml_w, ecx, &combined_ty_params);
|
||||
|
||||
|
@ -507,7 +507,7 @@ impl FlowedMoveData {
|
||||
for self.dfcx_moves.each_bit_on_entry_frozen(id) |index| {
|
||||
let move = &self.move_data.moves[index];
|
||||
let moved_path = move.path;
|
||||
if base_indices.contains(&moved_path) {
|
||||
if base_indices.iter().any_(|x| x == &moved_path) {
|
||||
// Scenario 1 or 2: `loan_path` or some base path of
|
||||
// `loan_path` was moved.
|
||||
if !f(move, self.move_data.path(moved_path).loan_path) {
|
||||
@ -536,7 +536,7 @@ impl FlowedMoveData {
|
||||
-> bool {
|
||||
//! True if `id` is the id of the LHS of an assignment
|
||||
|
||||
self.move_data.assignee_ids.contains(&id)
|
||||
self.move_data.assignee_ids.iter().any_(|x| x == &id)
|
||||
}
|
||||
|
||||
pub fn each_assignment_of(&self,
|
||||
|
@ -3710,7 +3710,7 @@ impl Resolver {
|
||||
let function_type_rib = @Rib(rib_kind);
|
||||
self.type_ribs.push(function_type_rib);
|
||||
|
||||
for generics.ty_params.eachi |index, type_parameter| {
|
||||
for generics.ty_params.iter().enumerate().advance |(index, type_parameter)| {
|
||||
let name = type_parameter.ident;
|
||||
debug!("with_type_parameter_rib: %d %d", node_id,
|
||||
type_parameter.id);
|
||||
|
@ -14,7 +14,6 @@ use cast::transmute;
|
||||
use container::Container;
|
||||
use iterator::IteratorUtil;
|
||||
use kinds::Copy;
|
||||
use old_iter;
|
||||
use option::Option;
|
||||
use sys;
|
||||
use uint;
|
||||
@ -129,7 +128,7 @@ pub fn map<T, U>(v: &[T], f: &fn(x: &T) -> U) -> @[U] {
|
||||
* Creates an immutable vector of size `n_elts` and initializes the elements
|
||||
* to the value returned by the function `op`.
|
||||
*/
|
||||
pub fn from_fn<T>(n_elts: uint, op: old_iter::InitOp<T>) -> @[T] {
|
||||
pub fn from_fn<T>(n_elts: uint, op: &fn(uint) -> T) -> @[T] {
|
||||
do build_sized(n_elts) |push| {
|
||||
let mut i: uint = 0u;
|
||||
while i < n_elts { push(op(i)); i += 1u; }
|
||||
|
@ -56,6 +56,18 @@ impl<'self, T> Clone for &'self T {
|
||||
fn clone(&self) -> &'self T { *self }
|
||||
}
|
||||
|
||||
impl<'self, T> Clone for &'self [T] {
|
||||
/// Return a shallow copy of the slice.
|
||||
#[inline]
|
||||
fn clone(&self) -> &'self [T] { *self }
|
||||
}
|
||||
|
||||
impl<'self> Clone for &'self str {
|
||||
/// Return a shallow copy of the slice.
|
||||
#[inline]
|
||||
fn clone(&self) -> &'self str { *self }
|
||||
}
|
||||
|
||||
macro_rules! clone_impl(
|
||||
($t:ty) => {
|
||||
impl Clone for $t {
|
||||
|
@ -138,7 +138,6 @@ pub mod from_str;
|
||||
#[path = "num/num.rs"]
|
||||
pub mod num;
|
||||
pub mod iter;
|
||||
pub mod old_iter;
|
||||
pub mod iterator;
|
||||
pub mod to_str;
|
||||
pub mod to_bytes;
|
||||
|
@ -20,7 +20,7 @@ implementing the `Iterator` trait.
|
||||
#[allow(default_methods)]; // solid enough for the use case here
|
||||
|
||||
use cmp;
|
||||
use iter::{FromIter, Times};
|
||||
use iter::Times;
|
||||
use num::{Zero, One};
|
||||
use option::{Option, Some, None};
|
||||
use ops::{Add, Mul};
|
||||
@ -240,7 +240,7 @@ pub trait IteratorUtil<A> {
|
||||
fn advance(&mut self, f: &fn(A) -> bool) -> bool;
|
||||
|
||||
/// Loops through the entire iterator, collecting all of the elements into
|
||||
/// a container implementing `FromIter`.
|
||||
/// a container implementing `FromIterator`.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
@ -249,7 +249,7 @@ pub trait IteratorUtil<A> {
|
||||
/// let b: ~[int] = a.iter().transform(|&x| x).collect();
|
||||
/// assert!(a == b);
|
||||
/// ~~~
|
||||
fn collect<B: FromIter<A>>(&mut self) -> B;
|
||||
fn collect<B: FromIterator<A, Self>>(&mut self) -> B;
|
||||
|
||||
/// Loops through `n` iterations, returning the `n`th element of the
|
||||
/// iterator.
|
||||
@ -411,8 +411,8 @@ impl<A, T: Iterator<A>> IteratorUtil<A> for T {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn collect<B: FromIter<A>>(&mut self) -> B {
|
||||
FromIter::from_iter::<A, B>(|f| self.advance(f))
|
||||
fn collect<B: FromIterator<A, T>>(&mut self) -> B {
|
||||
FromIterator::from_iterator(self)
|
||||
}
|
||||
|
||||
/// Return the `n`th item yielded by an iterator.
|
||||
|
@ -1,296 +0,0 @@
|
||||
// Copyright 2012-2013 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.
|
||||
|
||||
/*!
|
||||
|
||||
**Deprecated** iteration traits and common implementations.
|
||||
|
||||
*/
|
||||
|
||||
#[allow(missing_doc)];
|
||||
|
||||
use cmp::Eq;
|
||||
use kinds::Copy;
|
||||
use option::{None, Option, Some};
|
||||
use vec;
|
||||
|
||||
/// A function used to initialize the elements of a sequence
|
||||
pub type InitOp<'self,T> = &'self fn(uint) -> T;
|
||||
|
||||
pub trait BaseIter<A> {
|
||||
fn each(&self, blk: &fn(v: &A) -> bool) -> bool;
|
||||
fn size_hint(&self) -> Option<uint>;
|
||||
}
|
||||
|
||||
pub trait ReverseIter<A>: BaseIter<A> {
|
||||
fn each_reverse(&self, blk: &fn(&A) -> bool) -> bool;
|
||||
}
|
||||
|
||||
pub trait ExtendedIter<A> {
|
||||
fn eachi(&self, blk: &fn(uint, v: &A) -> bool) -> bool;
|
||||
fn all(&self, blk: &fn(&A) -> bool) -> bool;
|
||||
fn any(&self, blk: &fn(&A) -> bool) -> bool;
|
||||
fn foldl<B>(&self, b0: B, blk: &fn(&B, &A) -> B) -> B;
|
||||
fn position(&self, f: &fn(&A) -> bool) -> Option<uint>;
|
||||
fn map_to_vec<B>(&self, op: &fn(&A) -> B) -> ~[B];
|
||||
fn flat_map_to_vec<B,IB: BaseIter<B>>(&self, op: &fn(&A) -> IB) -> ~[B];
|
||||
}
|
||||
|
||||
pub trait EqIter<A:Eq> {
|
||||
fn contains(&self, x: &A) -> bool;
|
||||
fn count(&self, x: &A) -> uint;
|
||||
}
|
||||
|
||||
pub trait CopyableIter<A:Copy> {
|
||||
fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A];
|
||||
fn to_vec(&self) -> ~[A];
|
||||
fn find(&self, p: &fn(&A) -> bool) -> Option<A>;
|
||||
}
|
||||
|
||||
// A trait for sequences that can be built by imperatively pushing elements
|
||||
// onto them.
|
||||
pub trait Buildable<A> {
|
||||
/**
|
||||
* Builds a buildable sequence by calling a provided function with
|
||||
* an argument function that pushes an element onto the back of
|
||||
* the sequence.
|
||||
* This version takes an initial size for the sequence.
|
||||
*
|
||||
* # Arguments
|
||||
*
|
||||
* * size - A hint for an initial size of the sequence
|
||||
* * builder - A function that will construct the sequence. It receives
|
||||
* as an argument a function that will push an element
|
||||
* onto the sequence being constructed.
|
||||
*/
|
||||
fn build_sized(size: uint, builder: &fn(push: &fn(A))) -> Self;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn _eachi<A,IA:BaseIter<A>>(this: &IA, blk: &fn(uint, &A) -> bool) -> bool {
|
||||
let mut i = 0;
|
||||
for this.each |a| {
|
||||
if !blk(i, a) {
|
||||
return false;
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
pub fn eachi<A,IA:BaseIter<A>>(this: &IA, blk: &fn(uint, &A) -> bool) -> bool {
|
||||
_eachi(this, blk)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn all<A,IA:BaseIter<A>>(this: &IA, blk: &fn(&A) -> bool) -> bool {
|
||||
for this.each |a| {
|
||||
if !blk(a) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn any<A,IA:BaseIter<A>>(this: &IA, blk: &fn(&A) -> bool) -> bool {
|
||||
for this.each |a| {
|
||||
if blk(a) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn filter_to_vec<A:Copy,IA:BaseIter<A>>(this: &IA,
|
||||
prd: &fn(&A) -> bool)
|
||||
-> ~[A] {
|
||||
do vec::build_sized_opt(this.size_hint()) |push| {
|
||||
for this.each |a| {
|
||||
if prd(a) { push(copy *a); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn map_to_vec<A,B,IA:BaseIter<A>>(this: &IA, op: &fn(&A) -> B) -> ~[B] {
|
||||
do vec::build_sized_opt(this.size_hint()) |push| {
|
||||
for this.each |a| {
|
||||
push(op(a));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn flat_map_to_vec<A,B,IA:BaseIter<A>,IB:BaseIter<B>>(this: &IA,
|
||||
op: &fn(&A) -> IB)
|
||||
-> ~[B] {
|
||||
do vec::build |push| {
|
||||
for this.each |a| {
|
||||
for op(a).each |&b| {
|
||||
push(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn foldl<A,B,IA:BaseIter<A>>(this: &IA, b0: B, blk: &fn(&B, &A) -> B)
|
||||
-> B {
|
||||
let mut b = b0;
|
||||
for this.each |a| {
|
||||
b = blk(&b, a);
|
||||
}
|
||||
b
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn to_vec<A:Copy,IA:BaseIter<A>>(this: &IA) -> ~[A] {
|
||||
map_to_vec(this, |&x| x)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn contains<A:Eq,IA:BaseIter<A>>(this: &IA, x: &A) -> bool {
|
||||
for this.each |a| {
|
||||
if *a == *x { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn count<A:Eq,IA:BaseIter<A>>(this: &IA, x: &A) -> uint {
|
||||
do foldl(this, 0) |count, value| {
|
||||
if *value == *x {
|
||||
*count + 1
|
||||
} else {
|
||||
*count
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn position<A,IA:BaseIter<A>>(this: &IA, f: &fn(&A) -> bool)
|
||||
-> Option<uint> {
|
||||
let mut i = 0;
|
||||
for this.each |a| {
|
||||
if f(a) { return Some(i); }
|
||||
i += 1;
|
||||
}
|
||||
return None;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn find<A:Copy,IA:BaseIter<A>>(this: &IA, f: &fn(&A) -> bool)
|
||||
-> Option<A> {
|
||||
for this.each |i| {
|
||||
if f(i) { return Some(copy *i) }
|
||||
}
|
||||
return None;
|
||||
}
|
||||
|
||||
// Some functions for just building
|
||||
|
||||
/**
|
||||
* Builds a sequence by calling a provided function with an argument
|
||||
* function that pushes an element to the back of a sequence.
|
||||
*
|
||||
* # Arguments
|
||||
*
|
||||
* * builder - A function that will construct the sequence. It receives
|
||||
* as an argument a function that will push an element
|
||||
* onto the sequence being constructed.
|
||||
*/
|
||||
#[inline]
|
||||
pub fn build<A,B: Buildable<A>>(builder: &fn(push: &fn(A))) -> B {
|
||||
Buildable::build_sized(4, builder)
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a sequence by calling a provided function with an argument
|
||||
* function that pushes an element to the back of the sequence.
|
||||
* This version takes an initial size for the sequence.
|
||||
*
|
||||
* # Arguments
|
||||
*
|
||||
* * size - An option, maybe containing initial size of the sequence
|
||||
* to reserve.
|
||||
* * builder - A function that will construct the sequence. It receives
|
||||
* as an argument a function that will push an element
|
||||
* onto the sequence being constructed.
|
||||
*/
|
||||
#[inline]
|
||||
pub fn build_sized_opt<A,B: Buildable<A>>(size: Option<uint>,
|
||||
builder: &fn(push: &fn(A))) -> B {
|
||||
Buildable::build_sized(size.get_or_default(4), builder)
|
||||
}
|
||||
|
||||
// Functions that combine iteration and building
|
||||
|
||||
/// Applies a function to each element of an iterable and returns the results
|
||||
/// in a sequence built via `BU`. See also `map_to_vec`.
|
||||
#[inline]
|
||||
pub fn map<T,IT: BaseIter<T>,U,BU: Buildable<U>>(v: &IT, f: &fn(&T) -> U)
|
||||
-> BU {
|
||||
do build_sized_opt(v.size_hint()) |push| {
|
||||
for v.each() |elem| {
|
||||
push(f(elem));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and initializes a generic sequence from a function.
|
||||
*
|
||||
* Creates a generic sequence of size `n_elts` and initializes the elements
|
||||
* to the value returned by the function `op`.
|
||||
*/
|
||||
#[inline]
|
||||
pub fn from_fn<T,BT: Buildable<T>>(n_elts: uint, op: InitOp<T>) -> BT {
|
||||
do Buildable::build_sized(n_elts) |push| {
|
||||
let mut i: uint = 0u;
|
||||
while i < n_elts { push(op(i)); i += 1u; }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and initializes a generic sequence with some elements.
|
||||
*
|
||||
* Creates an immutable vector of size `n_elts` and initializes the elements
|
||||
* to the value `t`.
|
||||
*/
|
||||
#[inline]
|
||||
pub fn from_elem<T:Copy,BT:Buildable<T>>(n_elts: uint, t: T) -> BT {
|
||||
do Buildable::build_sized(n_elts) |push| {
|
||||
let mut i: uint = 0;
|
||||
while i < n_elts { push(copy t); i += 1; }
|
||||
}
|
||||
}
|
||||
|
||||
/// Appends two generic sequences.
|
||||
#[inline]
|
||||
pub fn append<T:Copy,IT:BaseIter<T>,BT:Buildable<T>>(lhs: &IT, rhs: &IT)
|
||||
-> BT {
|
||||
let size_opt = lhs.size_hint().chain_ref(
|
||||
|sz1| rhs.size_hint().map(|sz2| *sz1+*sz2));
|
||||
do build_sized_opt(size_opt) |push| {
|
||||
for lhs.each |x| { push(copy *x); }
|
||||
for rhs.each |x| { push(copy *x); }
|
||||
}
|
||||
}
|
||||
|
||||
/// Copies a generic sequence, possibly converting it to a different
|
||||
/// type of sequence.
|
||||
#[inline]
|
||||
pub fn copy_seq<T:Copy,IT:BaseIter<T>,BT:Buildable<T>>(v: &IT) -> BT {
|
||||
do build_sized_opt(v.size_hint()) |push| {
|
||||
for v.each |x| { push(copy *x); }
|
||||
}
|
||||
}
|
@ -46,8 +46,6 @@ pub use cmp::{Eq, ApproxEq, Ord, TotalEq, TotalOrd, Ordering, Less, Equal, Great
|
||||
pub use char::Char;
|
||||
pub use container::{Container, Mutable, Map, Set};
|
||||
pub use hash::Hash;
|
||||
pub use old_iter::{BaseIter, ReverseIter, ExtendedIter, EqIter};
|
||||
pub use old_iter::CopyableIter;
|
||||
pub use iter::{Times, FromIter};
|
||||
pub use iterator::{Iterator, IteratorUtil, OrdIterator};
|
||||
pub use num::{Num, NumCast};
|
||||
|
@ -15,7 +15,6 @@ use super::io::net::ip::IpAddr;
|
||||
use super::uv::*;
|
||||
use super::rtio::*;
|
||||
use ops::Drop;
|
||||
use old_iter::CopyableIter;
|
||||
use cell::Cell;
|
||||
use cast::transmute;
|
||||
use super::sched::{Scheduler, local_sched};
|
||||
|
@ -29,7 +29,6 @@ use iterator::{Iterator, IteratorUtil, FilterIterator, AdditiveIterator, MapIter
|
||||
use libc;
|
||||
use num::Zero;
|
||||
use option::{None, Option, Some};
|
||||
use old_iter::EqIter;
|
||||
use ptr;
|
||||
use ptr::RawPtr;
|
||||
use to_str::ToStr;
|
||||
@ -2225,7 +2224,6 @@ mod tests {
|
||||
use option::Some;
|
||||
use libc::c_char;
|
||||
use libc;
|
||||
use old_iter::BaseIter;
|
||||
use ptr;
|
||||
use str::*;
|
||||
use vec;
|
||||
|
@ -21,7 +21,6 @@ use iterator::IteratorUtil;
|
||||
use container::Map;
|
||||
use hash::Hash;
|
||||
use cmp::Eq;
|
||||
use old_iter::BaseIter;
|
||||
use vec::ImmutableVector;
|
||||
use iterator::IteratorUtil;
|
||||
|
||||
|
@ -176,22 +176,6 @@ pub struct TrieSet {
|
||||
priv map: TrieMap<()>
|
||||
}
|
||||
|
||||
impl BaseIter<uint> for TrieSet {
|
||||
/// Visit all values in order
|
||||
#[inline]
|
||||
fn each(&self, f: &fn(&uint) -> bool) -> bool { self.map.each_key(f) }
|
||||
#[inline]
|
||||
fn size_hint(&self) -> Option<uint> { Some(self.len()) }
|
||||
}
|
||||
|
||||
impl ReverseIter<uint> for TrieSet {
|
||||
/// Visit all values in reverse order
|
||||
#[inline]
|
||||
fn each_reverse(&self, f: &fn(&uint) -> bool) -> bool {
|
||||
self.map.each_key_reverse(f)
|
||||
}
|
||||
}
|
||||
|
||||
impl Container for TrieSet {
|
||||
/// Return the number of elements in the set
|
||||
#[inline]
|
||||
@ -234,6 +218,16 @@ impl TrieSet {
|
||||
pub fn remove(&mut self, value: &uint) -> bool {
|
||||
self.map.remove(value)
|
||||
}
|
||||
|
||||
/// Visit all values in order
|
||||
#[inline]
|
||||
pub fn each(&self, f: &fn(&uint) -> bool) -> bool { self.map.each_key(f) }
|
||||
|
||||
/// Visit all values in reverse order
|
||||
#[inline]
|
||||
pub fn each_reverse(&self, f: &fn(&uint) -> bool) -> bool {
|
||||
self.map.each_key_reverse(f)
|
||||
}
|
||||
}
|
||||
|
||||
struct TrieNode<T> {
|
||||
|
@ -17,7 +17,6 @@ use cast;
|
||||
use container::{Container, Mutable};
|
||||
use cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering, Less, Equal, Greater};
|
||||
use clone::Clone;
|
||||
use old_iter;
|
||||
use iterator::{FromIterator, Iterator, IteratorUtil};
|
||||
use iter::FromIter;
|
||||
use kinds::Copy;
|
||||
@ -124,7 +123,7 @@ pub fn capacity<T>(v: &const ~[T]) -> uint {
|
||||
* Creates an owned vector of size `n_elts` and initializes the elements
|
||||
* to the value returned by the function `op`.
|
||||
*/
|
||||
pub fn from_fn<T>(n_elts: uint, op: old_iter::InitOp<T>) -> ~[T] {
|
||||
pub fn from_fn<T>(n_elts: uint, op: &fn(uint) -> T) -> ~[T] {
|
||||
unsafe {
|
||||
let mut v = with_capacity(n_elts);
|
||||
do as_mut_buf(v) |p, _len| {
|
||||
@ -815,7 +814,7 @@ pub fn grow<T:Copy>(v: &mut ~[T], n: uint, initval: &T) {
|
||||
* * init_op - A function to call to retreive each appended element's
|
||||
* value
|
||||
*/
|
||||
pub fn grow_fn<T>(v: &mut ~[T], n: uint, op: old_iter::InitOp<T>) {
|
||||
pub fn grow_fn<T>(v: &mut ~[T], n: uint, op: &fn(uint) -> T) {
|
||||
let new_len = v.len() + n;
|
||||
reserve_at_least(&mut *v, new_len);
|
||||
let mut i: uint = 0u;
|
||||
@ -1985,7 +1984,7 @@ pub trait OwnedVector<T> {
|
||||
fn consume_reverse(self, f: &fn(uint, v: T));
|
||||
fn filter(self, f: &fn(t: &T) -> bool) -> ~[T];
|
||||
fn partition(self, f: &fn(&T) -> bool) -> (~[T], ~[T]);
|
||||
fn grow_fn(&mut self, n: uint, op: old_iter::InitOp<T>);
|
||||
fn grow_fn(&mut self, n: uint, op: &fn(uint) -> T);
|
||||
}
|
||||
|
||||
impl<T> OwnedVector<T> for ~[T] {
|
||||
@ -2064,7 +2063,7 @@ impl<T> OwnedVector<T> for ~[T] {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn grow_fn(&mut self, n: uint, op: old_iter::InitOp<T>) {
|
||||
fn grow_fn(&mut self, n: uint, op: &fn(uint) -> T) {
|
||||
grow_fn(self, n, op);
|
||||
}
|
||||
}
|
||||
@ -2501,7 +2500,17 @@ impl<T> FromIter<T> for ~[T]{
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
impl<A, T: Iterator<A>> FromIterator<A, T> for ~[A] {
|
||||
pub fn from_iterator(iterator: &mut T) -> ~[A] {
|
||||
let mut xs = ~[];
|
||||
for iterator.advance |x| {
|
||||
xs.push(x);
|
||||
}
|
||||
xs
|
||||
}
|
||||
}
|
||||
|
||||
/* FIXME: #7341 - ICE
|
||||
impl<A, T: Iterator<A>> FromIterator<A, T> for ~[A] {
|
||||
pub fn from_iterator(iterator: &mut T) -> ~[A] {
|
||||
let (lower, _) = iterator.size_hint();
|
||||
@ -2512,6 +2521,7 @@ impl<A, T: Iterator<A>> FromIterator<A, T> for ~[A] {
|
||||
xs
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
@ -375,7 +375,7 @@ impl gen_init for protocol {
|
||||
let mut params: OptVec<ast::TyParam> = opt_vec::Empty;
|
||||
for (copy self.states).iter().advance |s| {
|
||||
for s.generics.ty_params.each |tp| {
|
||||
match params.find(|tpp| tp.ident == tpp.ident) {
|
||||
match params.iter().find_(|tpp| tp.ident == tpp.ident) {
|
||||
None => params.push(*tp),
|
||||
_ => ()
|
||||
}
|
||||
@ -393,7 +393,7 @@ impl gen_init for protocol {
|
||||
let mut params: OptVec<ast::TyParam> = opt_vec::Empty;
|
||||
let fields = do (copy self.states).iter().transform |s| {
|
||||
for s.generics.ty_params.each |tp| {
|
||||
match params.find(|tpp| tp.ident == tpp.ident) {
|
||||
match params.iter().find_(|tpp| tp.ident == tpp.ident) {
|
||||
None => params.push(*tp),
|
||||
_ => ()
|
||||
}
|
||||
|
@ -17,9 +17,7 @@
|
||||
*/
|
||||
|
||||
use core::prelude::*;
|
||||
|
||||
use core::old_iter;
|
||||
use core::old_iter::BaseIter;
|
||||
use core::vec::VecIterator;
|
||||
|
||||
#[deriving(Encodable, Decodable)]
|
||||
pub enum OptVec<T> {
|
||||
@ -40,6 +38,13 @@ pub fn from<T>(t: ~[T]) -> OptVec<T> {
|
||||
}
|
||||
|
||||
impl<T> OptVec<T> {
|
||||
fn each(&self, blk: &fn(v: &T) -> bool) -> bool {
|
||||
match *self {
|
||||
Empty => true,
|
||||
Vec(ref v) => v.iter().advance(blk)
|
||||
}
|
||||
}
|
||||
|
||||
fn push(&mut self, t: T) {
|
||||
match *self {
|
||||
Vec(ref mut v) => {
|
||||
@ -78,6 +83,28 @@ impl<T> OptVec<T> {
|
||||
Vec(ref v) => v.len()
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn iter<'r>(&'r self) -> OptVecIterator<'r, T> {
|
||||
match *self {
|
||||
Empty => OptVecIterator{iter: None},
|
||||
Vec(ref v) => OptVecIterator{iter: Some(v.iter())}
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn map_to_vec<B>(&self, op: &fn(&T) -> B) -> ~[B] {
|
||||
self.iter().transform(op).collect()
|
||||
}
|
||||
|
||||
fn mapi_to_vec<B>(&self, op: &fn(uint, &T) -> B) -> ~[B] {
|
||||
let mut index = 0;
|
||||
self.map_to_vec(|a| {
|
||||
let i = index;
|
||||
index += 1;
|
||||
op(i, a)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub fn take_vec<T>(v: OptVec<T>) -> ~[T] {
|
||||
@ -96,22 +123,6 @@ impl<T:Copy> OptVec<T> {
|
||||
}
|
||||
return Vec(v0);
|
||||
}
|
||||
|
||||
fn push_all<I: BaseIter<T>>(&mut self, from: &I) {
|
||||
for from.each |e| {
|
||||
self.push(copy *e);
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn mapi_to_vec<B>(&self, op: &fn(uint, &T) -> B) -> ~[B] {
|
||||
let mut index = 0;
|
||||
old_iter::map_to_vec(self, |a| {
|
||||
let i = index;
|
||||
index += 1;
|
||||
op(i, a)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl<A:Eq> Eq for OptVec<A> {
|
||||
@ -131,68 +142,16 @@ impl<A:Eq> Eq for OptVec<A> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<A> BaseIter<A> for OptVec<A> {
|
||||
fn each(&self, blk: &fn(v: &A) -> bool) -> bool {
|
||||
match *self {
|
||||
Empty => true,
|
||||
Vec(ref v) => v.iter().advance(blk)
|
||||
pub struct OptVecIterator<'self, T> {
|
||||
priv iter: Option<VecIterator<'self, T>>
|
||||
}
|
||||
|
||||
impl<'self, T> Iterator<&'self T> for OptVecIterator<'self, T> {
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<&'self T> {
|
||||
match self.iter {
|
||||
Some(ref mut x) => x.next(),
|
||||
None => None
|
||||
}
|
||||
}
|
||||
|
||||
fn size_hint(&self) -> Option<uint> {
|
||||
Some(self.len())
|
||||
}
|
||||
}
|
||||
|
||||
impl<A> old_iter::ExtendedIter<A> for OptVec<A> {
|
||||
#[inline]
|
||||
fn eachi(&self, blk: &fn(v: uint, v: &A) -> bool) -> bool {
|
||||
old_iter::eachi(self, blk)
|
||||
}
|
||||
#[inline]
|
||||
fn all(&self, blk: &fn(&A) -> bool) -> bool {
|
||||
old_iter::all(self, blk)
|
||||
}
|
||||
#[inline]
|
||||
fn any(&self, blk: &fn(&A) -> bool) -> bool {
|
||||
old_iter::any(self, blk)
|
||||
}
|
||||
#[inline]
|
||||
fn foldl<B>(&self, b0: B, blk: &fn(&B, &A) -> B) -> B {
|
||||
old_iter::foldl(self, b0, blk)
|
||||
}
|
||||
#[inline]
|
||||
fn position(&self, f: &fn(&A) -> bool) -> Option<uint> {
|
||||
old_iter::position(self, f)
|
||||
}
|
||||
#[inline]
|
||||
fn map_to_vec<B>(&self, op: &fn(&A) -> B) -> ~[B] {
|
||||
old_iter::map_to_vec(self, op)
|
||||
}
|
||||
#[inline]
|
||||
fn flat_map_to_vec<B,IB:BaseIter<B>>(&self, op: &fn(&A) -> IB)
|
||||
-> ~[B] {
|
||||
old_iter::flat_map_to_vec(self, op)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
impl<A: Eq> old_iter::EqIter<A> for OptVec<A> {
|
||||
#[inline]
|
||||
fn contains(&self, x: &A) -> bool { old_iter::contains(self, x) }
|
||||
#[inline]
|
||||
fn count(&self, x: &A) -> uint { old_iter::count(self, x) }
|
||||
}
|
||||
|
||||
impl<A: Copy> old_iter::CopyableIter<A> for OptVec<A> {
|
||||
#[inline]
|
||||
fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A] {
|
||||
old_iter::filter_to_vec(self, pred)
|
||||
}
|
||||
#[inline]
|
||||
fn to_vec(&self) -> ~[A] { old_iter::to_vec(self) }
|
||||
#[inline]
|
||||
fn find(&self, f: &fn(&A) -> bool) -> Option<A> {
|
||||
old_iter::find(self, f)
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,6 @@
|
||||
// Instead the failure will be delivered after the callbacks return.
|
||||
|
||||
use std::libc;
|
||||
use std::old_iter;
|
||||
use std::task;
|
||||
|
||||
mod rustrt {
|
||||
|
@ -1,6 +1,4 @@
|
||||
// xfail-test
|
||||
// xfail'd because of a problem with by-value self.
|
||||
|
||||
// xfail-test #5321
|
||||
// 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.
|
||||
|
@ -1,60 +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.
|
||||
|
||||
// xfail-test
|
||||
|
||||
use to_str::*;
|
||||
use to_str::to_str;
|
||||
|
||||
class cat : to_str {
|
||||
priv {
|
||||
let mut meows : uint;
|
||||
fn meow() {
|
||||
error!("Meow");
|
||||
self.meows += 1u;
|
||||
if self.meows % 5u == 0u {
|
||||
self.how_hungry += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut how_hungry : int;
|
||||
let name : str;
|
||||
|
||||
new(in_x : uint, in_y : int, in_name: str)
|
||||
{ self.meows = in_x; self.how_hungry = in_y; self.name = in_name; }
|
||||
|
||||
fn speak() { self.meow(); }
|
||||
|
||||
fn eat() -> bool {
|
||||
if self.how_hungry > 0 {
|
||||
error!("OM NOM NOM");
|
||||
self.how_hungry -= 2;
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
error!("Not hungry!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
fn to_str() -> str { self.name }
|
||||
}
|
||||
|
||||
fn print_out<T:to_str>(thing: T, expected: str) {
|
||||
let actual = thing.to_str();
|
||||
debug!("%s", actual);
|
||||
assert_eq!(actual, expected);
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let nyan : to_str = cat(0u, 2, "nyan") as to_str;
|
||||
print_out(nyan, "nyan");
|
||||
}
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// xfail-test
|
||||
// xfail-test FIXME #7307
|
||||
// xfail-fast
|
||||
|
||||
extern mod extra;
|
||||
|
@ -13,7 +13,6 @@
|
||||
use std::cmp;
|
||||
use std::container::{Container, Mutable, Map};
|
||||
use std::int;
|
||||
use std::old_iter::BaseIter;
|
||||
use std::uint;
|
||||
|
||||
enum cat_type { tuxedo, tabby, tortoiseshell }
|
||||
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// xfail-test
|
||||
// xfail-test FIXME #7305
|
||||
|
||||
extern mod extra;
|
||||
use extra::oldmap::*;
|
||||
|
@ -1,35 +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.
|
||||
|
||||
// xfail-test
|
||||
|
||||
extern mod extra;
|
||||
use extra::oldmap::{map, hashmap, int_hash};
|
||||
|
||||
class keys<K:Copy,V:Copy,M:Copy + map<K,V>>
|
||||
: old_iter::base_iter<K> {
|
||||
|
||||
let map: M;
|
||||
|
||||
new(map: M) {
|
||||
self.map = map;
|
||||
}
|
||||
|
||||
fn each(blk: &fn(K) -> bool) { self.map.each(|k, _v| blk(k) ) }
|
||||
fn size_hint() -> Option<uint> { Some(self.map.size()) }
|
||||
fn eachi(blk: &fn(uint, K) -> bool) { old_iter::eachi(self, blk) }
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let m = int_hash();
|
||||
m.insert(1, 2);
|
||||
m.insert(3, 4);
|
||||
assert_eq!(old_iter::to_vec(keys(m)), ~[1, 3]);
|
||||
}
|
@ -1,8 +1,6 @@
|
||||
// xfail-test
|
||||
|
||||
fn sum(x: &[int]) -> int {
|
||||
let mut sum = 0;
|
||||
for x.each |y| { sum += *y; }
|
||||
for x.iter().advance |y| { sum += *y; }
|
||||
return sum;
|
||||
}
|
||||
|
||||
@ -14,8 +12,10 @@ fn sum_imm(y: &[int]) -> int {
|
||||
sum(y)
|
||||
}
|
||||
|
||||
/* FIXME #7304
|
||||
fn sum_const(y: &const [int]) -> int {
|
||||
sum(y)
|
||||
}
|
||||
*/
|
||||
|
||||
pub fn main() {}
|
||||
|
@ -1,20 +1,20 @@
|
||||
// xfail-test
|
||||
|
||||
/* FIXME #7302
|
||||
fn foo(v: &const [uint]) -> ~[uint] {
|
||||
v.to_vec()
|
||||
v.to_owned()
|
||||
}
|
||||
*/
|
||||
|
||||
fn bar(v: &mut [uint]) -> ~[uint] {
|
||||
v.to_vec()
|
||||
v.to_owned()
|
||||
}
|
||||
|
||||
fn bip(v: &[uint]) -> ~[uint] {
|
||||
v.to_vec()
|
||||
v.to_owned()
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let mut the_vec = ~[1, 2, 3, 100];
|
||||
assert_eq!(the_vec, foo(the_vec));
|
||||
assert_eq!(the_vec, bar(the_vec));
|
||||
assert_eq!(the_vec, bip(the_vec));
|
||||
let mut the_vec = ~[1u, 2, 3, 100];
|
||||
// assert_eq!(the_vec.clone(), foo(the_vec));
|
||||
assert_eq!(the_vec.clone(), bar(the_vec));
|
||||
assert_eq!(the_vec.clone(), bip(the_vec));
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
// xfail-test #7103 `extern mod` does not work on windows
|
||||
// xfail-fast #7103 `extern mod` does not work on windows
|
||||
// xfail-pretty - does not converge
|
||||
|
||||
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
|
@ -10,6 +10,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// xfail-fast
|
||||
|
||||
#[deriving] //~ WARNING empty trait list in `deriving`
|
||||
struct Foo;
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
// Just a test that new-style extern mods parse
|
||||
|
||||
// xfail-test
|
||||
// xfail-test FIXME #6407
|
||||
extern mod test = "github.com/catamorphism/test-pkg";
|
||||
|
||||
fn main() {}
|
||||
fn main() {}
|
||||
|
@ -8,12 +8,9 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// xfail-test
|
||||
|
||||
extern mod extra;
|
||||
use std::sys;
|
||||
|
||||
pub fn main() {
|
||||
// Bare functions should just be a pointer
|
||||
assert!(sys::rustrt::size_of::<fn()>() ==
|
||||
sys::rustrt::size_of::<int>());
|
||||
assert_eq!(sys::size_of::<extern "Rust" fn()>(), sys::size_of::<int>());
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// xfail-test
|
||||
// xfail-test FIXME #7308
|
||||
// -*- rust -*-
|
||||
|
||||
native mod libc = target_libc {
|
||||
|
@ -8,10 +8,11 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// xfail-test
|
||||
// xfail-test FIXME #1866
|
||||
mod a {
|
||||
pub type rust_task = uint;
|
||||
pub mod rustrt {
|
||||
use super::rust_task;
|
||||
pub extern {
|
||||
pub fn rust_task_is_unwinding(rt: *rust_task) -> bool;
|
||||
}
|
||||
@ -21,6 +22,7 @@ mod a {
|
||||
mod b {
|
||||
pub type rust_task = bool;
|
||||
pub mod rustrt {
|
||||
use super::rust_task;
|
||||
pub extern {
|
||||
pub fn rust_task_is_unwinding(rt: *rust_task) -> bool;
|
||||
}
|
||||
|
@ -1,30 +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.
|
||||
|
||||
// xfail-test
|
||||
extern mod extra;
|
||||
use extra::arena;
|
||||
use extra::arena::Arena;
|
||||
|
||||
enum hold { s(str) }
|
||||
|
||||
fn init(ar: &a.arena::Arena, str: str) -> &a.hold {
|
||||
new(*ar) s(str)
|
||||
}
|
||||
|
||||
pub fn main(args: ~[str]) {
|
||||
let ar = arena::Arena();
|
||||
let leak = init(&ar, args[0]);
|
||||
match *leak {
|
||||
s(astr) {
|
||||
io::println(fmt!("%?", astr));
|
||||
}
|
||||
};
|
||||
}
|
@ -8,23 +8,23 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// xfail-test
|
||||
// xfail-test FIXME #2190
|
||||
mod a {
|
||||
fn foo(f: &fn()) { f() }
|
||||
fn bar() {}
|
||||
pub fn main() { foo(||bar()); }
|
||||
fn foo(f: &fn()) { f() }
|
||||
fn bar() {}
|
||||
pub fn main() { foo(||bar()); }
|
||||
}
|
||||
|
||||
mod b {
|
||||
fn foo(f: Option<&fn()>) { f.iter(|x|x()) }
|
||||
fn bar() {}
|
||||
pub fn main() { foo(Some(bar)); }
|
||||
fn foo(f: Option<&fn()>) { f.iter(|x|x()) }
|
||||
fn bar() {}
|
||||
pub fn main() { foo(Some(bar)); }
|
||||
}
|
||||
|
||||
mod c {
|
||||
fn foo(f: Option<&fn()>) { f.iter(|x|x()) }
|
||||
fn bar() {}
|
||||
pub fn main() { foo(Some(||bar())); }
|
||||
fn foo(f: Option<&fn()>) { f.iter(|x|x()) }
|
||||
fn bar() {}
|
||||
pub fn main() { foo(Some(||bar())); }
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// xfail-test
|
||||
// xfail-test FIXME #3290
|
||||
fn main() {
|
||||
let mut x = ~3;
|
||||
x = x;
|
||||
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// xfail-test
|
||||
// xfail-test FIXME #3796
|
||||
#[deny(dead_assignment)];
|
||||
fn main() {
|
||||
let mut x = 1;
|
||||
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// xfail-test
|
||||
// xfail-test FIXME #3874
|
||||
enum PureCounter { PureCounter(uint) }
|
||||
|
||||
fn each(self: PureCounter, blk: &fn(v: &uint)) {
|
||||
|
@ -9,16 +9,17 @@
|
||||
// except according to those terms.
|
||||
|
||||
// xfail-test
|
||||
|
||||
trait A {
|
||||
fn a_method();
|
||||
fn a_method(&self);
|
||||
}
|
||||
|
||||
trait B: A {
|
||||
fn b_method();
|
||||
fn b_method(&self);
|
||||
}
|
||||
|
||||
trait C: B {
|
||||
fn c_method() {
|
||||
fn c_method(&self) {
|
||||
self.a_method();
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// xfail-test
|
||||
// xfail-test FIXME #5946
|
||||
trait Positioned<S> {
|
||||
fn SetX(&mut self, S);
|
||||
fn X(&self) -> S;
|
||||
|
@ -8,11 +8,15 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// xfail-test
|
||||
// xfail-fast
|
||||
|
||||
extern mod extra;
|
||||
|
||||
use extra::net::tcp::TcpSocketBuf;
|
||||
|
||||
use std::io;
|
||||
use std::int;
|
||||
|
||||
use std::io::{ReaderUtil,WriterUtil};
|
||||
|
||||
enum Result {
|
||||
@ -97,9 +101,9 @@ priv fn cmd_to_str(cmd: ~[~str]) -> ~str {
|
||||
let mut res = ~"*";
|
||||
res.push_str(cmd.len().to_str());
|
||||
res.push_str("\r\n");
|
||||
for cmd.each |s| {
|
||||
for cmd.iter().advance |s| {
|
||||
res.push_str([~"$", s.len().to_str(), ~"\r\n",
|
||||
copy *s, ~"\r\n"].concat()));
|
||||
copy *s, ~"\r\n"].concat() );
|
||||
}
|
||||
res
|
||||
}
|
||||
|
@ -8,9 +8,10 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// xfail-test
|
||||
use std::io;
|
||||
|
||||
fn parse_args() -> ~str {
|
||||
let args = std::os::args();
|
||||
let args = ::std::os::args();
|
||||
let mut n = 0;
|
||||
|
||||
while n < args.len() {
|
||||
|
@ -8,9 +8,11 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// xfail-test
|
||||
use std::os;
|
||||
|
||||
pub fn main() {
|
||||
for os::args().each |arg| {
|
||||
let x = os::args();
|
||||
for x.iter().advance |arg| {
|
||||
match arg.clone() {
|
||||
s => { }
|
||||
}
|
||||
|
@ -1,5 +1,3 @@
|
||||
// xfail-test
|
||||
|
||||
// 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.
|
||||
@ -10,6 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// xfail-test
|
||||
// aux-build:issue_3882.rc
|
||||
extern mod linenoise;
|
||||
use linenoise::issue_3882::*;
|
||||
|
@ -8,9 +8,6 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// xfail-fast
|
||||
// xfail-test
|
||||
|
||||
pub fn main() {
|
||||
'foo: loop {
|
||||
loop {
|
||||
|
@ -1,6 +1,8 @@
|
||||
// xfail-test
|
||||
// FIXME #7306
|
||||
// xfail-fast
|
||||
// -*- rust -*-
|
||||
|
||||
use std::io;
|
||||
|
||||
fn f1(ref_string: &str) {
|
||||
match ref_string {
|
||||
"a" => io::println("found a"),
|
||||
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// xfail-test
|
||||
// FIXME #7303: xfail-test
|
||||
|
||||
// Protocols
|
||||
proto! foo (
|
||||
|
@ -11,23 +11,30 @@
|
||||
// xfail-test
|
||||
// This checks that preemption works.
|
||||
|
||||
fn starve_main(alive: chan<int>) {
|
||||
// note: halfway done porting to modern rust
|
||||
extern mod extra;
|
||||
|
||||
use std::comm;
|
||||
use extra::comm;
|
||||
|
||||
fn starve_main(alive: Port<int>) {
|
||||
debug!("signalling main");
|
||||
alive.recv(1);
|
||||
alive.recv();
|
||||
debug!("starving main");
|
||||
let i: int = 0;
|
||||
let mut i: int = 0;
|
||||
loop { i += 1; }
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let alive: port<int> = port();
|
||||
let (port, chan) = stream();
|
||||
|
||||
debug!("main started");
|
||||
let s: task = do task::spawn {
|
||||
starve_main(chan(alive));
|
||||
do spawn {
|
||||
starve_main(port);
|
||||
};
|
||||
let i: int;
|
||||
let mut i: int = 0;
|
||||
debug!("main waiting for alive signal");
|
||||
alive.send(i);
|
||||
chan.send(i);
|
||||
debug!("main got alive signal");
|
||||
while i < 50 { debug!("main iterated"); i += 1; }
|
||||
debug!("main completed");
|
||||
|
@ -1,6 +1,3 @@
|
||||
// xfail-test
|
||||
// xfail'd due to segfaults with by-value self.
|
||||
|
||||
// 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.
|
||||
@ -15,26 +12,24 @@ trait get {
|
||||
fn get(self) -> int;
|
||||
}
|
||||
|
||||
// Note: impl on a slice
|
||||
impl get for &'self int {
|
||||
// FIXME #7302: Note: impl on a slice
|
||||
impl<'self> get for &'self int {
|
||||
fn get(self) -> int {
|
||||
return **self;
|
||||
return *self;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
/*
|
||||
let x = @mut 6;
|
||||
let y = x.get();
|
||||
assert_eq!(y, 6);
|
||||
*/
|
||||
|
||||
let x = @6;
|
||||
let y = x.get();
|
||||
debug!("y=%d", y);
|
||||
assert_eq!(y, 6);
|
||||
|
||||
let mut x = ~6;
|
||||
let x = ~6;
|
||||
let y = x.get();
|
||||
debug!("y=%d", y);
|
||||
assert_eq!(y, 6);
|
||||
|
@ -8,8 +8,6 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// xfail-test
|
||||
|
||||
fn foo(x: &[uint]) -> uint {
|
||||
x[0]
|
||||
}
|
||||
|
@ -8,8 +8,6 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// xfail-test
|
||||
|
||||
static foo: int = 4 >> 1;
|
||||
enum bs { thing = foo }
|
||||
pub fn main() { assert!((thing as int == foo)); }
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
// xfail-test
|
||||
|
||||
use std::ptr;
|
||||
|
||||
enum a_tag<A,B> {
|
||||
varA(A),
|
||||
varB(B)
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
// xfail-test
|
||||
|
||||
use std::ptr;
|
||||
|
||||
enum a_tag {
|
||||
a_tag(u64)
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
// xfail-test
|
||||
// xfail-test FIXME #5882
|
||||
// Weird borrow check bug
|
||||
|
||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
||||
@ -17,45 +17,45 @@ struct Tree(@mut TreeR);
|
||||
struct TreeR {
|
||||
left: Option<Tree>,
|
||||
right: Option<Tree>,
|
||||
val: to_str
|
||||
val: ~to_str
|
||||
}
|
||||
|
||||
trait to_str {
|
||||
fn to_str(&self) -> ~str;
|
||||
fn to_str_(&self) -> ~str;
|
||||
}
|
||||
|
||||
impl<T:to_str> to_str for Option<T> {
|
||||
fn to_str(&self) -> ~str {
|
||||
fn to_str_(&self) -> ~str {
|
||||
match *self {
|
||||
None => { ~"none" }
|
||||
Some(ref t) => { ~"some(" + t.to_str() + ~")" }
|
||||
Some(ref t) => { ~"some(" + t.to_str_() + ~")" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl to_str for int {
|
||||
fn to_str(&self) -> ~str { int::str(*self) }
|
||||
fn to_str_(&self) -> ~str { self.to_str() }
|
||||
}
|
||||
|
||||
impl to_str for Tree {
|
||||
fn to_str(&self) -> ~str {
|
||||
let l = self.left, r = self.right;
|
||||
fn to_str_(&self) -> ~str {
|
||||
let (l, r) = (self.left, self.right);
|
||||
let val = &self.val;
|
||||
fmt!("[%s, %s, %s]", val.to_str(), l.to_str(), r.to_str())
|
||||
fmt!("[%s, %s, %s]", val.to_str_(), l.to_str_(), r.to_str_())
|
||||
}
|
||||
}
|
||||
|
||||
fn foo<T:to_str>(x: T) -> ~str { x.to_str() }
|
||||
fn foo<T:to_str>(x: T) -> ~str { x.to_str_() }
|
||||
|
||||
pub fn main() {
|
||||
let t1 = Tree(@mut TreeR{left: None,
|
||||
right: None,
|
||||
val: 1 as to_str });
|
||||
val: ~1 as ~to_str });
|
||||
let t2 = Tree(@mut TreeR{left: Some(t1),
|
||||
right: Some(t1),
|
||||
val: 2 as to_str });
|
||||
val: ~2 as ~to_str });
|
||||
let expected = ~"[2, some([1, none, none]), some([1, none, none])]";
|
||||
assert_eq!(t2.to_str(), expected);
|
||||
assert_eq!(foo(t2 as to_str), expected);
|
||||
assert!(t2.to_str_() == expected);
|
||||
assert!(foo(t2) == expected);
|
||||
t1.left = Some(t2); // create cycle
|
||||
}
|
||||
|
@ -1,55 +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.
|
||||
|
||||
//xfail-test
|
||||
|
||||
// Sketching traits.
|
||||
|
||||
// methods with no implementation are required; methods with an
|
||||
// implementation are provided. No "req" keyword necessary.
|
||||
trait Eq {
|
||||
fn eq(a: self) -> bool;
|
||||
|
||||
fn neq(a: self) -> bool {
|
||||
!self.eq(a)
|
||||
}
|
||||
}
|
||||
|
||||
// The `<` is pronounced `extends`. Also under consideration is `<:`.
|
||||
// Just using `:` is frowned upon, because (paraphrasing dherman) `:`
|
||||
// is supposed to separate things from different universes.
|
||||
trait Ord < Eq {
|
||||
|
||||
fn lt(a: self) -> bool;
|
||||
|
||||
fn lte(a: self) -> bool {
|
||||
self.lt(a) || self.eq(a)
|
||||
}
|
||||
|
||||
fn gt(a: self) -> bool {
|
||||
!self.lt(a) && !self.eq(a)
|
||||
}
|
||||
|
||||
fn gte(a: self) -> bool {
|
||||
!self.lt(a)
|
||||
}
|
||||
}
|
||||
|
||||
// pronounced "impl of Ord for int" -- not sold on this yet
|
||||
impl Ord for int {
|
||||
fn lt(a: &int) -> bool {
|
||||
self < (*a)
|
||||
}
|
||||
|
||||
// is this the place to put this?
|
||||
fn eq(a: &int) -> bool {
|
||||
self == (*a)
|
||||
}
|
||||
}
|
@ -9,14 +9,15 @@
|
||||
// except according to those terms.
|
||||
|
||||
// xfail-test
|
||||
// See #3283
|
||||
fn foo(blk: &fn(p: &'a fn() -> &'a fn())) {
|
||||
let mut state = 0;
|
||||
let statep = &mut state;
|
||||
// FIXME: #7336: codegen bug makes this segfault on Linux x86_64
|
||||
|
||||
fn foo<'a>(blk: &fn(p: &'a fn() -> &'a fn())) {
|
||||
let mut state = 0;
|
||||
let statep = &mut state;
|
||||
do blk {
|
||||
|| { *statep = 1; }
|
||||
}
|
||||
}
|
||||
fn main() {
|
||||
do foo |p| { p()() }
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user