Add block_to_str and expr_to_str methods to the pprust module.
Since pprust is authed impure these can be used for debug logging.
This commit is contained in:
parent
2490cd3275
commit
d631f29d47
1 changed files with 18 additions and 0 deletions
|
@ -32,6 +32,24 @@ fn ty_to_str(&@ast.ty ty) -> str {
|
|||
ret writer.get_str();
|
||||
}
|
||||
|
||||
fn block_to_str(&ast.block blk) -> str {
|
||||
auto writer = io.string_writer();
|
||||
auto s = @rec(s=pp.mkstate(writer.get_writer(), 78u),
|
||||
comments=option.none[vec[lexer.cmnt]],
|
||||
mutable cur_cmnt=0u);
|
||||
print_block(s, blk);
|
||||
ret writer.get_str();
|
||||
}
|
||||
|
||||
fn expr_to_str(&@ast.expr e) -> str {
|
||||
auto writer = io.string_writer();
|
||||
auto s = @rec(s=pp.mkstate(writer.get_writer(), 78u),
|
||||
comments=option.none[vec[lexer.cmnt]],
|
||||
mutable cur_cmnt=0u);
|
||||
print_expr(s, e);
|
||||
ret writer.get_str();
|
||||
}
|
||||
|
||||
impure fn hbox(ps s) {
|
||||
pp.hbox(s.s, indent_unit);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue