diff options
| author | Jorge Aparicio <japaricious@gmail.com> | 2014-12-08 13:28:32 -0500 |
|---|---|---|
| committer | Jorge Aparicio <japaricious@gmail.com> | 2014-12-13 17:03:47 -0500 |
| commit | 0dac05dd627612232403c07ca8bd6d3376eec64a (patch) | |
| tree | 656a23a7314866c8fa5cc6ca787111db41d90834 /src/libsyntax/ast_map/mod.rs | |
| parent | 2160427900ea675e494274d42a8d8485724f440e (diff) | |
libsyntax: use unboxed closures
Diffstat (limited to 'src/libsyntax/ast_map/mod.rs')
| -rw-r--r-- | src/libsyntax/ast_map/mod.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/libsyntax/ast_map/mod.rs b/src/libsyntax/ast_map/mod.rs index 2c985f403f8..907ac6b19fc 100644 --- a/src/libsyntax/ast_map/mod.rs +++ b/src/libsyntax/ast_map/mod.rs @@ -424,7 +424,9 @@ impl<'ast> Map<'ast> { } } - pub fn with_path<T>(&self, id: NodeId, f: |PathElems| -> T) -> T { + pub fn with_path<T, F>(&self, id: NodeId, f: F) -> T where + F: FnOnce(PathElems) -> T, + { self.with_path_next(id, None, f) } @@ -438,7 +440,9 @@ impl<'ast> Map<'ast> { }) } - fn with_path_next<T>(&self, id: NodeId, next: LinkedPath, f: |PathElems| -> T) -> T { + fn with_path_next<T, F>(&self, id: NodeId, next: LinkedPath, f: F) -> T where + F: FnOnce(PathElems) -> T, + { let parent = self.get_parent(id); let parent = match self.find_entry(id) { Some(EntryForeignItem(..)) | Some(EntryVariant(..)) => { @@ -470,7 +474,9 @@ impl<'ast> Map<'ast> { /// Given a node ID and a closure, apply the closure to the array /// of attributes associated with the AST corresponding to the Node ID - pub fn with_attrs<T>(&self, id: NodeId, f: |Option<&[Attribute]>| -> T) -> T { + pub fn with_attrs<T, F>(&self, id: NodeId, f: F) -> T where + F: FnOnce(Option<&[Attribute]>) -> T, + { let attrs = match self.get(id) { NodeItem(i) => Some(i.attrs.as_slice()), NodeForeignItem(fi) => Some(fi.attrs.as_slice()), |
