#. type: Plain text
#: doc/rust.md:2849
msgid ""
-"type Binop<'self> = &'self fn(int,int) -> int; let bo: Binop = add; x = "
+"type Binop<'self> = 'self |int,int| -> int; let bo: Binop = add; x = "
"bo(5,7); ~~~~~~~~"
msgstr ""
#. type: Plain text
#: doc/rust.md:2849
msgid ""
-"type Binop<'self> = &'self fn(int,int) -> int; let bo: Binop = add; x = "
+"type Binop<'self> = 'self |int,int| -> int; let bo: Binop = add; x = "
"bo(5,7); ~~~~~~~~"
msgstr ""
let mut x = add(5,7);
-type Binop<'self> = &'self fn(int,int) -> int;
+type Binop<'self> = 'self |int,int| -> int;
let bo: Binop = add;
x = bo(5,7);
~~~~
use std::util::swap;
use std::vec;
-type Le<'self, T> = &'self fn(v1: &T, v2: &T) -> bool;
+type Le<'self, T> = 'self |v1: &T, v2: &T| -> bool;
/**
* Merge sort. Returns a new vector containing the sorted list.
use syntax::{ast, fold, attr};
struct Context<'self> {
- in_cfg: &'self fn(attrs: &[ast::Attribute]) -> bool,
+ in_cfg: 'self |attrs: &[ast::Attribute]| -> bool,
}
// Support conditional compilation by transforming the AST, stripping out
ret
}
-pub type GetCrateDataCb<'self> = &'self fn(ast::CrateNum) -> Cmd;
+pub type GetCrateDataCb<'self> = 'self |ast::CrateNum| -> Cmd;
pub fn maybe_find_item(item_id: int, items: ebml::Doc) -> Option<ebml::Doc> {
fn eq_item(bytes: &[u8], item_id: int) -> bool {
cdata: Cmd,
get_crate_data: GetCrateDataCb<'self>,
path_builder: &'self mut ~str,
- callback: &'self fn(&str, DefLike, ast::visibility) -> bool,
+ callback: 'self |&str, DefLike, ast::visibility| -> bool,
}
impl<'self> EachItemContext<'self> {
item_path(lookup_item(id, cdata.data))
}
-pub type decode_inlined_item<'self> = &'self fn(
- cdata: @cstore::crate_metadata,
- tcx: ty::ctxt,
- path: ast_map::path,
- par_doc: ebml::Doc) -> Option<ast::inlined_item>;
+pub type decode_inlined_item<'self> = 'self |cdata: @cstore::crate_metadata,
+ tcx: ty::ctxt,
+ path: ast_map::path,
+ par_doc: ebml::Doc|
+ -> Option<ast::inlined_item>;
pub fn maybe_get_item_ast(cdata: Cmd, tcx: ty::ctxt,
id: ast::NodeId,
// used by astencode:
type abbrev_map = @mut HashMap<ty::t, tyencode::ty_abbrev>;
-pub type encode_inlined_item<'self> = &'self fn(ecx: &EncodeContext,
- ebml_w: &mut writer::Encoder,
- path: &[ast_map::path_elt],
- ii: ast::inlined_item);
+pub type encode_inlined_item<'self> = 'self |ecx: &EncodeContext,
+ ebml_w: &mut writer::Encoder,
+ path: &[ast_map::path_elt],
+ ii: ast::inlined_item|;
pub struct EncodeParams<'self> {
diag: @mut span_handler,
/// Functions with type `pick` take a parent directory as well as
/// a file found in that directory.
-pub type pick<'self> = &'self fn(path: &Path) -> FileMatch;
+pub type pick<'self> = 'self |path: &Path| -> FileMatch;
pub fn pick_file(file: Path, path: &Path) -> Option<Path> {
if path.filename() == Some(file.as_vec()) {
RegionParameter,
}
type conv_did<'self> =
- &'self fn(source: DefIdSource, ast::DefId) -> ast::DefId;
+ 'self |source: DefIdSource, ast::DefId| -> ast::DefId;
pub struct PState<'self> {
data: &'self [u8],
}
}
-type enter_pat<'self> = &'self fn(@ast::Pat) -> Option<~[@ast::Pat]>;
+type enter_pat<'self> = 'self |@ast::Pat| -> Option<~[@ast::Pat]>;
fn enter_match<'r>(bcx: @mut Block,
dm: DefMap,
}
}
-pub type val_and_ty_fn<'self> = &'self fn(@mut Block, ValueRef, ty::t) -> @mut Block;
+pub type val_and_ty_fn<'self> = 'self |@mut Block, ValueRef, ty::t|
+ -> @mut Block;
pub fn load_inbounds(cx: @mut Block, p: ValueRef, idxs: &[uint]) -> ValueRef {
return Load(cx, GEPi(cx, p, idxs));
return inf;
}
-pub type glue_helper<'self> = &'self fn(@mut Block, ValueRef, ty::t) -> @mut Block;
+pub type glue_helper<'self> = 'self |@mut Block, ValueRef, ty::t|
+ -> @mut Block;
pub fn declare_generic_glue(ccx: &mut CrateContext, t: ty::t, llfnty: Type,
name: &str) -> ValueRef {
}
}
-pub type iter_vec_block<'self> = &'self fn(@mut Block, ValueRef, ty::t) -> @mut Block;
+pub type iter_vec_block<'self> = 'self |@mut Block, ValueRef, ty::t|
+ -> @mut Block;
pub fn iter_vec_loop(bcx: @mut Block,
data_ptr: ValueRef,
pub struct BottomUpFolder<'self> {
tcx: ty::ctxt,
- fldop: &'self fn(ty::t) -> ty::t,
+ fldop: 'self |ty::t| -> ty::t,
}
impl<'self> TypeFolder for BottomUpFolder<'self> {
pub struct RegionFolder<'self> {
tcx: ty::ctxt,
- fld_t: &'self fn(ty::t) -> ty::t,
- fld_r: &'self fn(ty::Region) -> ty::Region,
+ fld_t: 'self |ty::t| -> ty::t,
+ fld_r: 'self |ty::Region| -> ty::Region,
}
impl<'self> RegionFolder<'self> {
pub fn general(tcx: ty::ctxt,
- fld_r: &'self fn(ty::Region) -> ty::Region,
- fld_t: &'self fn(ty::t) -> ty::t)
+ fld_r: 'self |ty::Region| -> ty::Region,
+ fld_t: 'self |ty::t| -> ty::t)
-> RegionFolder<'self> {
RegionFolder {
tcx: tcx,
}
}
- pub fn regions(tcx: ty::ctxt,
- fld_r: &'self fn(ty::Region) -> ty::Region)
+ pub fn regions(tcx: ty::ctxt, fld_r: 'self |ty::Region| -> ty::Region)
-> RegionFolder<'self> {
fn noop(t: ty::t) -> ty::t { t }
struct RegionRelator<'self> {
tcx: ty::ctxt,
stack: ~[ty::Region],
- relate_op: &'self fn(ty::Region, ty::Region),
+ relate_op: 'self |ty::Region, ty::Region|,
}
// FIXME(#10151) -- Define more precisely when a region is
}
pub type LatticeOp<'self, T> =
- &'self fn(cf: &CombineFields, a: &T, b: &T) -> cres<T>;
+ 'self |cf: &CombineFields, a: &T, b: &T| -> cres<T>;
impl LatticeValue for ty::t {
fn sub(cf: &CombineFields, a: &ty::t, b: &ty::t) -> ures {
}
}
-pub type LatticeDirOp<'self, T> = &'self fn(a: &T, b: &T) -> cres<T>;
+pub type LatticeDirOp<'self, T> = 'self |a: &T, b: &T| -> cres<T>;
#[deriving(Clone)]
pub enum LatticeVarResult<V,T> {
}
struct LoopQueryVisitor<'self> {
- p: &'self fn(&ast::Expr_) -> bool,
+ p: 'self |&ast::Expr_| -> bool,
flag: bool,
}
}
struct BlockQueryVisitor<'self> {
- p: &'self fn(@ast::Expr) -> bool,
+ p: 'self |@ast::Expr| -> bool,
flag: bool,
}
}
fn path(w: &mut io::Writer, path: &clean::Path, print_all: bool,
- root: &fn(&render::Cache, &[~str]) -> Option<~str>,
- info: &fn(&render::Cache) -> Option<(~[~str], &'static str)>) {
+ root: |&render::Cache, &[~str]| -> Option<~str>,
+ info: |&render::Cache| -> Option<(~[~str], &'static str)>) {
// The generics will get written to both the title and link
let mut generics = ~"";
let last = path.segments.last();
/// things like ".." to components which preserve the "top down" hierarchy of a
/// static HTML tree.
// FIXME (#9639): The closure should deal with &[u8] instead of &str
-fn clean_srcpath(src: &[u8], f: &fn(&str)) {
+fn clean_srcpath(src: &[u8], f: |&str|) {
let p = Path::new(src);
if p.as_vec() != bytes!(".") {
for c in p.str_components().map(|x|x.unwrap()) {
impl Context {
/// Recurse in the directory structure and change the "root path" to make
/// sure it always points to the top (relatively)
- fn recurse<T>(&mut self, s: ~str, f: &fn(&mut Context) -> T) -> T {
+ fn recurse<T>(&mut self, s: ~str, f: |&mut Context| -> T) -> T {
if s.len() == 0 {
fail!("what {:?}", self);
}
/// all sub-items which need to be rendered.
///
/// The rendering driver uses this closure to queue up more work.
- fn item(&mut self, item: clean::Item, f: &fn(&mut Context, clean::Item)) {
+ fn item(&mut self, item: clean::Item, f: |&mut Context, clean::Item|) {
fn render(w: io::File, cx: &mut Context, it: &clean::Item,
pushname: bool) {
// A little unfortunate that this is done like this, but it sure
use std::io;
use std::io::fs;
-pub fn list_installed_packages(f: &fn(&PkgId) -> bool) -> bool {
+pub fn list_installed_packages(f: |&PkgId| -> bool) -> bool {
let workspaces = rust_path();
for p in workspaces.iter() {
let binfiles = do io::ignore_io_error { fs::readdir(&p.join("bin")) };
self.find_crates_with_filter(|_| true);
}
- pub fn find_crates_with_filter(&mut self, filter: &fn(&str) -> bool) {
+ pub fn find_crates_with_filter(&mut self, filter: |&str| -> bool) {
use conditions::missing_pkg_files::cond;
let prefix = self.start_dir.components().len();
pub fn workspace_contains_package_id_(pkgid: &PkgId, workspace: &Path,
// Returns the directory it was actually found in
- workspace_to_src_dir: &fn(&Path) -> Path) -> Option<Path> {
+ workspace_to_src_dir: |&Path| -> Path) -> Option<Path> {
if !workspace.is_dir() {
return None;
}
trait FixedBuffer {
/// Input a vector of bytes. If the buffer becomes full, process it with the provided
/// function and then clear the buffer.
- fn input(&mut self, input: &[u8], func: &fn(&[u8]));
+ fn input(&mut self, input: &[u8], func: |&[u8]|);
/// Reset the buffer.
fn reset(&mut self);
}
impl FixedBuffer for FixedBuffer64 {
- fn input(&mut self, input: &[u8], func: &fn(&[u8])) {
+ fn input(&mut self, input: &[u8], func: |&[u8]|) {
let mut i = 0;
let size = 64;
/// and is guaranteed to have exactly rem remaining bytes when it returns. If there are not at
/// least rem bytes available, the buffer will be zero padded, processed, cleared, and then
/// filled with zeros again until only rem bytes are remaining.
- fn standard_padding(&mut self, rem: uint, func: &fn(&[u8]));
+ fn standard_padding(&mut self, rem: uint, func: |&[u8]|);
}
impl <T: FixedBuffer> StandardPadding for T {
- fn standard_padding(&mut self, rem: uint, func: &fn(&[u8])) {
+ fn standard_padding(&mut self, rem: uint, func: |&[u8]|) {
let size = self.size();
self.next(1)[0] = 128;
sess: session::Session,
exec: &'self mut workcache::Exec,
c: &'self ast::Crate,
- save: &'self fn(Path),
+ save: 'self |Path|,
deps: &'self mut DepMap
}
exec: &mut workcache::Exec,
c: &ast::Crate,
deps: &mut DepMap,
- save: &fn(Path)) {
+ save: |Path|) {
debug!("In find_and_install_dependencies...");
let mut visitor = ViewItemVisitor {
context: context,
use util::option_to_vec;
use package_id::PkgId;
-pub fn each_pkg_parent_workspace(cx: &Context, pkgid: &PkgId, action: &fn(&Path) -> bool) -> bool {
+pub fn each_pkg_parent_workspace(cx: &Context,
+ pkgid: &PkgId,
+ action: |&Path| -> bool)
+ -> bool {
// Using the RUST_PATH, find workspaces that contain
// this package ID
let workspaces = pkg_parent_workspaces(cx, pkgid);
use unstable::intrinsics::TyDesc;
use unstable::raw;
-type DropGlue<'self> = &'self fn(**TyDesc, *c_void);
+type DropGlue<'self> = 'self |**TyDesc, *c_void|;
/*
* Box annihilation
/// // use `trap`'s inside method to register the handler and then run a
/// // block of code with the handler registered
/// ```
- pub fn trap<'a>(&'a self, h: &'a fn(T) -> U) -> Trap<'a, T, U> {
+ pub fn trap<'a>(&'a self, h: 'a |T| -> U) -> Trap<'a, T, U> {
let h: Closure = unsafe { ::cast::transmute(h) };
let prev = local_data::get(self.key, |k| k.map(|x| *x));
let h = @Handler { handle: h, prev: prev };
/// };
/// assert_eq!(result, 7);
/// ```
- pub fn inside<V>(&self, inner: &'self fn() -> V) -> V {
+ pub fn inside<V>(&self, inner: 'self || -> V) -> V {
let _g = Guard { cond: self.cond };
debug!("Trap: pushing handler to TLS");
local_data::set(self.cond.key, self.handler);
/// assert!(it.next().is_none());
/// ```
#[inline]
- fn map<'r, B>(self, f: &'r fn(A) -> B) -> Map<'r, A, B, Self> {
+ fn map<'r, B>(self, f: 'r |A| -> B) -> Map<'r, A, B, Self> {
Map{iter: self, f: f}
}
/// assert!(it.next().is_none());
/// ```
#[inline]
- fn filter<'r>(self, predicate: &'r fn(&A) -> bool) -> Filter<'r, A, Self> {
+ fn filter<'r>(self, predicate: 'r |&A| -> bool) -> Filter<'r, A, Self> {
Filter{iter: self, predicate: predicate}
}
/// assert!(it.next().is_none());
/// ```
#[inline]
- fn filter_map<'r, B>(self, f: &'r fn(A) -> Option<B>) -> FilterMap<'r, A, B, Self> {
+ fn filter_map<'r, B>(self, f: 'r |A| -> Option<B>) -> FilterMap<'r, A, B, Self> {
FilterMap { iter: self, f: f }
}
/// assert!(it.next().is_none());
/// ```
#[inline]
- fn skip_while<'r>(self, predicate: &'r fn(&A) -> bool) -> SkipWhile<'r, A, Self> {
+ fn skip_while<'r>(self, predicate: 'r |&A| -> bool) -> SkipWhile<'r, A, Self> {
SkipWhile{iter: self, flag: false, predicate: predicate}
}
/// assert!(it.next().is_none());
/// ```
#[inline]
- fn take_while<'r>(self, predicate: &'r fn(&A) -> bool) -> TakeWhile<'r, A, Self> {
+ fn take_while<'r>(self, predicate: 'r |&A| -> bool) -> TakeWhile<'r, A, Self> {
TakeWhile{iter: self, flag: false, predicate: predicate}
}
/// assert!(it.next().is_none());
/// ```
#[inline]
- fn scan<'r, St, B>(self, initial_state: St, f: &'r fn(&mut St, A) -> Option<B>)
+ fn scan<'r, St, B>(self, initial_state: St, f: 'r |&mut St, A| -> Option<B>)
-> Scan<'r, A, B, Self, St> {
Scan{iter: self, f: f, state: initial_state}
}
/// }
/// ```
#[inline]
- fn flat_map<'r, B, U: Iterator<B>>(self, f: &'r fn(A) -> U)
+ fn flat_map<'r, B, U: Iterator<B>>(self, f: 'r |A| -> U)
-> FlatMap<'r, A, Self, U> {
FlatMap{iter: self, f: f, frontiter: None, backiter: None }
}
///println(sum.to_str());
/// ```
#[inline]
- fn inspect<'r>(self, f: &'r fn(&A)) -> Inspect<'r, A, Self> {
+ fn inspect<'r>(self, f: 'r |&A|) -> Inspect<'r, A, Self> {
Inspect{iter: self, f: f}
}
/// An iterator which maps the values of `iter` with `f`
pub struct Map<'self, A, B, T> {
priv iter: T,
- priv f: &'self fn(A) -> B
+ priv f: 'self |A| -> B
}
impl<'self, A, B, T> Map<'self, A, B, T> {
/// An iterator which filters the elements of `iter` with `predicate`
pub struct Filter<'self, A, T> {
priv iter: T,
- priv predicate: &'self fn(&A) -> bool
+ priv predicate: 'self |&A| -> bool
}
impl<'self, A, T: Iterator<A>> Iterator<A> for Filter<'self, A, T> {
/// An iterator which uses `f` to both filter and map elements from `iter`
pub struct FilterMap<'self, A, B, T> {
priv iter: T,
- priv f: &'self fn(A) -> Option<B>
+ priv f: 'self |A| -> Option<B>
}
impl<'self, A, B, T: Iterator<A>> Iterator<B> for FilterMap<'self, A, B, T> {
pub struct SkipWhile<'self, A, T> {
priv iter: T,
priv flag: bool,
- priv predicate: &'self fn(&A) -> bool
+ priv predicate: 'self |&A| -> bool
}
impl<'self, A, T: Iterator<A>> Iterator<A> for SkipWhile<'self, A, T> {
pub struct TakeWhile<'self, A, T> {
priv iter: T,
priv flag: bool,
- priv predicate: &'self fn(&A) -> bool
+ priv predicate: 'self |&A| -> bool
}
impl<'self, A, T: Iterator<A>> Iterator<A> for TakeWhile<'self, A, T> {
/// An iterator to maintain state while iterating another iterator
pub struct Scan<'self, A, B, T, St> {
priv iter: T,
- priv f: &'self fn(&mut St, A) -> Option<B>,
+ priv f: 'self |&mut St, A| -> Option<B>,
/// The current internal state to be passed to the closure next.
state: St
///
pub struct FlatMap<'self, A, T, U> {
priv iter: T,
- priv f: &'self fn(A) -> U,
+ priv f: 'self |A| -> U,
priv frontiter: Option<U>,
priv backiter: Option<U>,
}
/// element before yielding it.
pub struct Inspect<'self, A, T> {
priv iter: T,
- priv f: &'self fn(&A)
+ priv f: 'self |&A|
}
impl<'self, A, T> Inspect<'self, A, T> {
/// An iterator which just modifies the contained state throughout iteration.
pub struct Unfold<'self, A, St> {
- priv f: &'self fn(&mut St) -> Option<A>,
+ priv f: 'self |&mut St| -> Option<A>,
/// Internal state that will be yielded on the next iteration
state: St
}
/// Creates a new iterator with the specified closure as the "iterator
/// function" and an initial state to eventually pass to the iterator
#[inline]
- pub fn new<'a>(initial_state: St, f: &'a fn(&mut St) -> Option<A>)
- -> Unfold<'a, A, St> {
+ pub fn new<'a>(initial_state: St, f: 'a |&mut St| -> Option<A>)
+ -> Unfold<'a, A, St> {
Unfold {
f: f,
state: initial_state
// the perf improvement (25-50%) is definitely worth the extra code
// size from force-inlining.
#[inline(always)]
-fn ziggurat<R:Rng>(rng: &mut R,
- symmetric: bool,
- X: ziggurat_tables::ZigTable,
- F: ziggurat_tables::ZigTable,
- pdf: &'static fn(f64) -> f64,
- zero_case: &'static fn(&mut R, f64) -> f64) -> f64 {
+fn ziggurat<R:Rng>(
+ rng: &mut R,
+ symmetric: bool,
+ X: ziggurat_tables::ZigTable,
+ F: ziggurat_tables::ZigTable,
+ pdf: 'static |f64| -> f64,
+ zero_case: 'static |&mut R, f64| -> f64)
+ -> f64 {
static SCALE: f64 = (1u64 << 53) as f64;
loop {
// reimplement the f64 generation as an optimisation suggested
fn only_ascii(&self) -> bool { (*self as uint) < 128 }
}
-impl<'self> CharEq for &'self fn(char) -> bool {
+impl<'self> CharEq for 'self |char| -> bool {
#[inline]
fn matches(&self, c: char) -> bool { (*self)(c) }
use str::{Str, StrSlice};
use vec::{Vector, ImmutableVector};
-pub type Cb<'self> = &'self fn(buf: &[u8]) -> bool;
+pub type Cb<'self> = 'self |buf: &[u8]| -> bool;
///
/// A trait to implement in order to make a type hashable;
}
}
-impl<'self,T> Finally<T> for &'self fn() -> T {
+impl<'self,T> Finally<T> for 'self || -> T {
fn finally(&self, dtor: ||) -> T {
let _d = Finallyalizer {
dtor: dtor
finally_fn!(extern "Rust" fn() -> T)
struct Finallyalizer<'self> {
- dtor: &'self fn()
+ dtor: 'self ||
}
#[unsafe_destructor]
pub struct SplitIterator<'self, T> {
priv v: &'self [T],
priv n: uint,
- priv pred: &'self fn(t: &T) -> bool,
+ priv pred: 'self |t: &T| -> bool,
priv finished: bool
}
pub struct RSplitIterator<'self, T> {
priv v: &'self [T],
priv n: uint,
- priv pred: &'self fn(t: &T) -> bool,
+ priv pred: 'self |t: &T| -> bool,
priv finished: bool
}
fn rev_iter(self) -> RevIterator<'self, T>;
/// Returns an iterator over the subslices of the vector which are
/// separated by elements that match `pred`.
- fn split(self, pred: &'self fn(&T) -> bool) -> SplitIterator<'self, T>;
+ fn split(self, pred: 'self |&T| -> bool) -> SplitIterator<'self, T>;
/// Returns an iterator over the subslices of the vector which are
/// separated by elements that match `pred`, limited to splitting
/// at most `n` times.
- fn splitn(self, n: uint, pred: &'self fn(&T) -> bool) -> SplitIterator<'self, T>;
+ fn splitn(self, n: uint, pred: |&T| -> bool) -> SplitIterator<'self, T>;
/// Returns an iterator over the subslices of the vector which are
/// separated by elements that match `pred`. This starts at the
/// end of the vector and works backwards.
- fn rsplit(self, pred: &'self fn(&T) -> bool) -> RSplitIterator<'self, T>;
+ fn rsplit(self, pred: |&T| -> bool) -> RSplitIterator<'self, T>;
/// Returns an iterator over the subslices of the vector which are
/// separated by elements that match `pred` limited to splitting
/// at most `n` times. This starts at the end of the vector and
/// works backwards.
- fn rsplitn(self, n: uint, pred: &'self fn(&T) -> bool) -> RSplitIterator<'self, T>;
+ fn rsplitn(self, n: uint, pred: 'self |&T| -> bool) -> RSplitIterator<'self, T>;
/**
* Returns an iterator over all contiguous windows of length
}
#[inline]
- fn split(self, pred: &'self fn(&T) -> bool) -> SplitIterator<'self, T> {
+ fn split(self, pred: 'self |&T| -> bool) -> SplitIterator<'self, T> {
self.splitn(uint::max_value, pred)
}
#[inline]
- fn splitn(self, n: uint, pred: &'self fn(&T) -> bool) -> SplitIterator<'self, T> {
+ fn splitn(self, n: uint, pred: 'self |&T| -> bool) -> SplitIterator<'self, T> {
SplitIterator {
v: self,
n: n,
}
#[inline]
- fn rsplit(self, pred: &'self fn(&T) -> bool) -> RSplitIterator<'self, T> {
+ fn rsplit(self, pred: 'self |&T| -> bool) -> RSplitIterator<'self, T> {
self.rsplitn(uint::max_value, pred)
}
#[inline]
- fn rsplitn(self, n: uint, pred: &'self fn(&T) -> bool) -> RSplitIterator<'self, T> {
+ fn rsplitn(self, n: uint, pred: 'self |&T| -> bool) -> RSplitIterator<'self, T> {
RSplitIterator {
v: self,
n: n,
}
struct EachViewItemData<'self> {
- callback: &'self fn(&ast::view_item) -> bool,
+ callback: 'self |&ast::view_item| -> bool,
}
impl<'self> Visitor<()> for EachViewItemData<'self> {
all the fields of all the structures, see above for details.
*/
pub type CombineSubstructureFunc<'self> =
- &'self fn(@ExtCtxt, Span, &Substructure) -> @Expr;
+ 'self |@ExtCtxt, Span, &Substructure| -> @Expr;
/**
Deal with non-matching enum variants, the arguments are a list
[variant fields]), and a list of the nonself args of the type
*/
pub type EnumNonMatchFunc<'self> =
- &'self fn(@ExtCtxt, Span,
- &[(uint, ast::variant,
- ~[(Span, Option<Ident>, @Expr)])],
- &[@Expr]) -> @Expr;
+ 'self |@ExtCtxt,
+ Span,
+ &[(uint, ast::variant, ~[(Span, Option<Ident>, @Expr)])],
+ &[@Expr]|
+ -> @Expr;
impl<'self> TraitDef<'self> {
pub mod generic;
-pub type ExpandDerivingStructDefFn<'self> = &'self fn(@ExtCtxt,
- Span,
- x: &struct_def,
- Ident,
- y: &Generics)
- -> @item;
-pub type ExpandDerivingEnumDefFn<'self> = &'self fn(@ExtCtxt,
- Span,
- x: &enum_def,
- Ident,
- y: &Generics)
+pub type ExpandDerivingStructDefFn<'self> = 'self |@ExtCtxt,
+ Span,
+ x: &struct_def,
+ Ident,
+ y: &Generics|
+ -> @item;
+pub type ExpandDerivingEnumDefFn<'self> = 'self |@ExtCtxt,
+ Span,
+ x: &enum_def,
+ Ident,
+ y: &Generics|
-> @item;
pub fn expand_meta_deriving(cx: @ExtCtxt,
// part of issue-6919.rs
struct C<'self> {
- k: &'self fn(),
+ k: 'self ||,
}
fn no_op() { }
// returns an infinite iterator of repeated applications of f to x,
// i.e. [x, f(x), f(f(x)), ...], as haskell iterate function.
-fn iterate<'a, T>(x: T, f: &'a fn(&T) -> T) -> Iterate<'a, T> {
+fn iterate<'a, T>(x: T, f: 'a |&T| -> T) -> Iterate<'a, T> {
Iterate {f: f, next: x}
}
struct Iterate<'self, T> {
- priv f: &'self fn(&T) -> T,
+ priv f: &'self |&T| -> T,
priv next: T
}
impl<'self, T> Iterator<T> for Iterate<'self, T> {
fn id<T>(t: T) -> T { t }
-fn f<'r, T>(v: &'r T) -> &'r fn()->T { id::<&'r fn()->T>(|| *v) } //~ ERROR cannot infer an appropriate lifetime
+fn f<'r, T>(v: &'r T) -> 'r || -> T {
+ id(|| *v) //~ ERROR cannot infer an appropriate lifetime
+}
fn main() {
let v = &5;
fn foopy() {}
-static f: &'static fn() = foopy; //~ ERROR found extern fn
+static f: 'static || = foopy; //~ ERROR found extern fn
fn main () {
f();
// This struct is needed to create the
// otherwise infinite type of a fn that
// accepts itself as argument:
- c: &'self fn(&R, bool)
+ c: 'self |&R, bool|
}
fn innocent_looking_victim() {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-fn wants_static_fn(_x: &'static fn()) {}
+fn wants_static_fn(_x: 'static ||) {}
fn main() {
let i = 3;
// except according to those terms.
struct parameterized1<'self> {
- g: &'self fn()
+ g: 'self ||
}
struct not_parameterized1 {
- g: &'static fn()
+ g: 'static ||
}
struct not_parameterized2 {
- g: &'static fn()
+ g: 'static ||
}
fn take1(p: parameterized1) -> parameterized1 { p }
#[feature(managed_boxes)];
struct invariant<'self> {
- f: &'static fn(x: @mut &'self int)
+ f: 'static |x: @mut &'self int|
}
fn to_same_lifetime<'r>(bi: invariant<'r>) {
#[feature(managed_boxes)];
struct invariant<'self> {
- f: &'static fn() -> @mut &'self int
+ f: 'static || -> @mut &'self int
}
fn to_same_lifetime<'r>(bi: invariant<'r>) {
struct indirect1 {
// Here the lifetime parameter of direct is bound by the fn()
- g: &'static fn(direct)
+ g: 'static |direct|
}
struct indirect2<'self> {
// But here it is set to 'self
- g: &'static fn(direct<'self>)
+ g: 'static |direct<'self>|
}
fn take_direct(p: direct) -> direct { p } //~ ERROR mismatched types
// except according to those terms.
struct closure_box<'self> {
- cl: &'self fn()
+ cl: 'self ||
}
-fn box_it<'r>(x: &'r fn()) -> closure_box<'r> {
+fn box_it<'r>(x: 'r ||) -> closure_box<'r> {
closure_box {cl: x}
}
let cheese = ~"roquefort";
let carrots = @~"crunchy";
- let result: &'static fn(@~str, |~str|) = (|tasties, macerate| {
+ let result: 'static |@~str, |~str|| = (|tasties, macerate| {
macerate((*tasties).clone());
});
result(carrots, |food| {
return 0xca7f000d;
}
-struct Bar<'self> { f: &'self fn() -> int }
+struct Bar<'self> { f: 'self || -> int }
static b : Bar<'static> = Bar { f: foo };
fn f() { }
static bare_fns: &'static [extern fn()] = &[f, f];
-struct S<'self>(&'self fn());
+struct S<'self>('self ||);
static closures: &'static [S<'static>] = &[S(f), S(f)];
pub fn main() {
fn test_fn() {
- type t = &'static fn() -> int;
+ type t = 'static || -> int;
fn ten() -> int { return 10; }
let rs: t = { ten };
assert!((rs() == 10));
#[feature(managed_boxes)];
-type compare<T> = &'static fn(@T, @T) -> bool;
+type compare<T> = 'static |@T, @T| -> bool;
fn test_generic<T>(expected: @T, eq: compare<T>) {
let actual: @T = { expected };
// xfail-fast
-type compare<'self, T> = &'self fn(T, T) -> bool;
+type compare<'self, T> = 'self |T, T| -> bool;
fn test_generic<T:Clone>(expected: T, eq: compare<T>) {
let actual: T = { expected.clone() };
-type compare<'self, T> = &'self fn(~T, ~T) -> bool;
+type compare<'self, T> = 'self |~T, ~T| -> bool;
fn test_generic<T:Clone>(expected: ~T, eq: compare<T>) {
let actual: ~T = { expected.clone() };
// xfail-fast
-type compare<'self, T> = &'self fn(T, T) -> bool;
+type compare<'self, T> = 'self |T, T| -> bool;
fn test_generic<T:Clone>(expected: T, eq: compare<T>) {
let actual: T = { expected.clone() };
// xfail-fast
// Tests for standalone blocks as expressions with dynamic type sizes
-type compare<'self, T> = &'self fn(T, T) -> bool;
+type compare<'self, T> = 'self |T, T| -> bool;
fn test_generic<T:Clone>(expected: T, eq: compare<T>) {
let actual: T = { expected.clone() };
#[feature(managed_boxes)];
-type compare<T> = &'static fn(@T, @T) -> bool;
+type compare<T> = 'static |@T, @T| -> bool;
fn test_generic<T>(expected: @T, not_expected: @T, eq: compare<T>) {
let actual: @T = if true { expected } else { not_expected };
// xfail-fast
-type compare<T> = &'static fn(T, T) -> bool;
+type compare<T> = 'static |T, T| -> bool;
fn test_generic<T:Clone>(expected: T, not_expected: T, eq: compare<T>) {
let actual: T = if true { expected.clone() } else { not_expected };
// xfail-fast
// Tests for if as expressions with dynamic type sizes
-type compare<T> = &'static fn(T, T) -> bool;
+type compare<T> = 'static |T, T| -> bool;
fn test_generic<T:Clone>(expected: T, not_expected: T, eq: compare<T>) {
let actual: T = if true { expected.clone() } else { not_expected };
#[feature(managed_boxes)];
-type compare<T> = &'static fn(@T, @T) -> bool;
+type compare<T> = 'static |@T, @T| -> bool;
fn test_generic<T>(expected: @T, eq: compare<T>) {
let actual: @T = match true { true => { expected }, _ => fail!() };
// xfail-fast
-type compare<T> = &'static fn(T, T) -> bool;
+type compare<T> = 'static |T, T| -> bool;
fn test_generic<T:Clone>(expected: T, eq: compare<T>) {
let actual: T = match true { true => { expected.clone() }, _ => fail!("wat") };
-type compare<T> = &'static fn(~T, ~T) -> bool;
+type compare<T> = 'static |~T, ~T| -> bool;
fn test_generic<T:Clone>(expected: ~T, eq: compare<T>) {
let actual: ~T = match true {
// xfail-fast
-type compare<'self, T> = &'self fn(T, T) -> bool;
+type compare<'self, T> = 'self |T, T| -> bool;
fn test_generic<T:Clone>(expected: T, eq: compare<T>) {
let actual: T = match true {
// except according to those terms.
struct r<'self> {
- field: &'self fn()
+ field: 'self ||
}
pub fn main() {
use std::str;
use std::task;
- pub type putter<'self> = &'self fn(~str, ~str);
+ pub type putter<'self> = 'self |~str, ~str|;
pub type mapper = extern fn(~str, putter);
// except according to those terms.
pub fn main() {
- let early_error: &'static fn(&str) -> ! = |_msg| { fail!() };
+ let early_error: 'static |&str| -> ! = |_msg| { fail!() };
}
//
// Running /usr/local/bin/rustc:
// issue-2185.rs:24:0: 26:1 error: conflicting implementations for a trait
-// issue-2185.rs:24 impl iterable<uint> for &'static fn(|uint|) {
+// issue-2185.rs:24 impl iterable<uint> for 'static ||uint|| {
// issue-2185.rs:25 fn iter(&self, blk: |v: uint|) { self( |i| blk(i) ) }
// issue-2185.rs:26 }
// issue-2185.rs:20:0: 22:1 note: note conflicting implementation here
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-type Connection = &'static fn(~[u8]);
+type Connection = 'static |~[u8]|;
fn f() -> Option<Connection> {
let mock_connection: Connection = |_| {};
struct A { a: ~int }
-fn foo() -> &'static fn() -> int {
+fn foo() -> 'static || -> int {
let k = ~22;
let _u = A {a: k.clone()};
- let result: &'static fn() -> int = || 22;
+ let result: 'static || -> int = || 22;
result
}
// except according to those terms.
struct closure_box<'self> {
- cl: &'self fn(),
+ cl: 'self ||,
}
-fn box_it<'r>(x: &'r fn()) -> closure_box<'r> {
+fn box_it<'r>(x: 'r ||) -> closure_box<'r> {
closure_box {cl: x}
}
// Test lifetimes are linked properly when we autoslice a vector.
// Issue #3148.
-fn subslice<'r>(v: &'r fn()) -> &'r fn() { v }
+fn subslice<'r>(v: 'r ||) -> 'r || { v }
-fn both<'r>(v: &'r fn()) -> &'r fn() {
+fn both<'r>(v: 'r ||) -> 'r || {
subslice(subslice(v))
}
// except according to those terms.
struct closure_box<'self> {
- cl: &'self fn(),
+ cl: 'self ||,
}
-fn box_it<'r>(x: &'r fn()) -> closure_box<'r> {
+fn box_it<'r>(x: 'r ||) -> closure_box<'r> {
closure_box {cl: x}
}