这是我抄的代码:
// Tested against syntex_syntax v0.33
extern crate syntex_syntax as syntax;
use std::rc::Rc;
use syntax::codemap::{CodeMap};
use syntax::errors::{Handler};
use syntax::errors::emitter::{ColorConfig};
use syntax::parse::{self, ParseSess};
fn main() {
let codemap = Rc::new(CodeMap::new());
let tty_handler =
Handler::with_tty_emitter(ColorConfig::Auto, None, true, false, codemap.clone());
let parse_session = ParseSess::with_span_handler(tty_handler, codemap.clone());
let src = "fn foo(x: i64) { let y = x + 1; return y; }".to_owned();
let result = parse::parse_crate_from_source_str(String::new(), src, Vec::new(), &parse_session);
println!("parse result: {:?}", result);
}
首先,要建立一个
[package]
name = "aa"
authors = ["me"]
version = "0.1.0"
[dependencies]
syntex_syntax = "0.59.1"
少一个字段就不行,rust说必须给我加上
.
然后cargo build
我叉,又是66个包
.编译非常之久.
我一运行,我叉,运行出错了.
,然后我把这个包删掉,我叉
,占用了我300M
,这都是一堆垃圾.为什么占用我这么多的空间.
总之,rust
不是我喜欢的类型,简直是搞笑
的语言.