Skip to content

Commit 6ecbfe9

Browse files
author
Darin Morrison
committed
Fix for namespaced enums
1 parent 2846acc commit 6ecbfe9

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

src/pretty/doc.rs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1-
use super::mode;
1+
use super::mode::{
2+
Mode,
3+
};
24
use super::util;
35
use std::io;
46

7+
pub use self::Doc::{
8+
Nil,
9+
Append,
10+
Group,
11+
Nest,
12+
Newline,
13+
Text,
14+
};
15+
516
#[deriving(Clone)]
617
#[deriving(Show)]
718
pub enum Doc {
@@ -13,7 +24,7 @@ pub enum Doc {
1324
Text(String),
1425
}
1526

16-
type Cmd<'a> = (uint,mode::Mode,&'a Doc);
27+
type Cmd<'a> = (uint, Mode, &'a Doc);
1728

1829
#[inline(always)]
1930
fn fitting<'a>(next:Cmd<'a>,
@@ -71,7 +82,7 @@ fn fitting<'a>(next:Cmd<'a>,
7182
pub fn best<W:io::Writer>(doc:&Doc, width:uint, out:&mut W) -> io::IoResult<()> {
7283
let mut res = Ok(());
7384
let mut pos = 0u;
74-
let mut bcmds = vec![(0, mode::Break, doc)];
85+
let mut bcmds = vec![(0, Mode::Break, doc)];
7586
let mut fcmds = vec![];
7687

7788
while res.is_ok() {
@@ -87,18 +98,18 @@ pub fn best<W:io::Writer>(doc:&Doc, width:uint, out:&mut W) -> io::IoResult<()>
8798
bcmds.push((ind, mode, ldoc));
8899
},
89100
&Group(box ref doc) => match mode {
90-
mode::Flat => {
91-
bcmds.push((ind, mode::Flat, doc));
101+
Mode::Flat => {
102+
bcmds.push((ind, Mode::Flat, doc));
92103
},
93-
mode::Break => {
94-
let next = (ind, mode::Flat, doc);
104+
Mode::Break => {
105+
let next = (ind, Mode::Flat, doc);
95106
if fitting(next,
96107
&bcmds,
97108
&mut fcmds,
98109
width as int - pos as int) {
99110
bcmds.push(next);
100111
} else {
101-
bcmds.push((ind, mode::Break, doc));
112+
bcmds.push((ind, Mode::Break, doc));
102113
}
103114
}
104115
},

src/pretty/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88
//! pretty-printing API.
99
1010
use doc::{
11+
best,
12+
};
13+
use doc::Doc::{
1114
Append,
1215
Group,
1316
Nest,
1417
Newline,
1518
Nil,
1619
Text,
17-
best,
1820
};
1921
use std::io;
2022

0 commit comments

Comments
 (0)