Skip to content

Commit a170183

Browse files
committed
librusti: Eliminate @fn.
1 parent 68ea9ae commit a170183

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

src/librusti/rusti.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ extern mod syntax;
7272

7373
use std::{libc, io, os, task};
7474
use std::cell::Cell;
75+
use extra::rl::CompletionCb;
7576
use extra::rl;
7677

7778
use rustc::driver::{driver, session};
@@ -520,6 +521,19 @@ pub fn main() {
520521
main_args(args);
521522
}
522523

524+
struct Completer;
525+
526+
impl CompletionCb for Completer {
527+
fn complete(&self, line: ~str, suggest: &fn(~str)) {
528+
if line.starts_with(":") {
529+
suggest(~":clear");
530+
suggest(~":exit");
531+
suggest(~":help");
532+
suggest(~":load");
533+
}
534+
}
535+
}
536+
523537
pub fn main_args(args: &[~str]) {
524538
#[fixed_stack_segment]; #[inline(never)];
525539

@@ -543,13 +557,8 @@ pub fn main_args(args: &[~str]) {
543557
println("unstable. If you encounter problems, please use the");
544558
println("compiler instead. Type :help for help.");
545559

546-
do rl::complete |line, suggest| {
547-
if line.starts_with(":") {
548-
suggest(~":clear");
549-
suggest(~":exit");
550-
suggest(~":help");
551-
suggest(~":load");
552-
}
560+
unsafe {
561+
rl::complete(@Completer as @CompletionCb)
553562
}
554563
}
555564

src/librusti/utils.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ use syntax::print::pprust;
1515
use syntax::parse::token;
1616
use syntax::visit;
1717

18-
struct EachBindingVisitor {
19-
f: @fn(&ast::Path, ast::NodeId)
18+
struct EachBindingVisitor<'self> {
19+
f: &'self fn(&ast::Path, ast::NodeId)
2020
}
2121

22-
impl visit::Visitor<()> for EachBindingVisitor {
22+
impl<'self> visit::Visitor<()> for EachBindingVisitor<'self> {
2323
fn visit_pat(&mut self, pat:@ast::Pat, _:()) {
2424
match pat.node {
2525
ast::PatIdent(_, ref path, _) => {
@@ -32,7 +32,7 @@ impl visit::Visitor<()> for EachBindingVisitor {
3232
}
3333
}
3434

35-
pub fn each_binding(l: @ast::Local, f: @fn(&ast::Path, ast::NodeId)) {
35+
pub fn each_binding(l: @ast::Local, f: &fn(&ast::Path, ast::NodeId)) {
3636
use syntax::visit::Visitor;
3737

3838
let mut vt = EachBindingVisitor{ f: f };

0 commit comments

Comments
 (0)