mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
librusti: Eliminate @fn
.
This commit is contained in:
parent
68ea9aed96
commit
a170183ba3
@ -72,6 +72,7 @@ extern mod syntax;
|
||||
|
||||
use std::{libc, io, os, task};
|
||||
use std::cell::Cell;
|
||||
use extra::rl::CompletionCb;
|
||||
use extra::rl;
|
||||
|
||||
use rustc::driver::{driver, session};
|
||||
@ -520,6 +521,19 @@ pub fn main() {
|
||||
main_args(args);
|
||||
}
|
||||
|
||||
struct Completer;
|
||||
|
||||
impl CompletionCb for Completer {
|
||||
fn complete(&self, line: ~str, suggest: &fn(~str)) {
|
||||
if line.starts_with(":") {
|
||||
suggest(~":clear");
|
||||
suggest(~":exit");
|
||||
suggest(~":help");
|
||||
suggest(~":load");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn main_args(args: &[~str]) {
|
||||
#[fixed_stack_segment]; #[inline(never)];
|
||||
|
||||
@ -543,13 +557,8 @@ pub fn main_args(args: &[~str]) {
|
||||
println("unstable. If you encounter problems, please use the");
|
||||
println("compiler instead. Type :help for help.");
|
||||
|
||||
do rl::complete |line, suggest| {
|
||||
if line.starts_with(":") {
|
||||
suggest(~":clear");
|
||||
suggest(~":exit");
|
||||
suggest(~":help");
|
||||
suggest(~":load");
|
||||
}
|
||||
unsafe {
|
||||
rl::complete(@Completer as @CompletionCb)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,11 +15,11 @@ use syntax::print::pprust;
|
||||
use syntax::parse::token;
|
||||
use syntax::visit;
|
||||
|
||||
struct EachBindingVisitor {
|
||||
f: @fn(&ast::Path, ast::NodeId)
|
||||
struct EachBindingVisitor<'self> {
|
||||
f: &'self fn(&ast::Path, ast::NodeId)
|
||||
}
|
||||
|
||||
impl visit::Visitor<()> for EachBindingVisitor {
|
||||
impl<'self> visit::Visitor<()> for EachBindingVisitor<'self> {
|
||||
fn visit_pat(&mut self, pat:@ast::Pat, _:()) {
|
||||
match pat.node {
|
||||
ast::PatIdent(_, ref path, _) => {
|
||||
@ -32,7 +32,7 @@ impl visit::Visitor<()> for EachBindingVisitor {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn each_binding(l: @ast::Local, f: @fn(&ast::Path, ast::NodeId)) {
|
||||
pub fn each_binding(l: @ast::Local, f: &fn(&ast::Path, ast::NodeId)) {
|
||||
use syntax::visit::Visitor;
|
||||
|
||||
let mut vt = EachBindingVisitor{ f: f };
|
||||
|
Loading…
Reference in New Issue
Block a user