Skip to content

Commit bb9e1e2

Browse files
committed
core: add Reader, Writer, ReaderUtil, WriterUtil to prelude. Close #4182.
1 parent 0847d52 commit bb9e1e2

File tree

4 files changed

+31
-28
lines changed

4 files changed

+31
-28
lines changed

src/libcore/io.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ use libc;
2121
use libc::{c_int, c_long, c_uint, c_void, size_t, ssize_t};
2222
use libc::consts::os::posix88::*;
2323
use os;
24-
use prelude::*;
24+
use cast;
25+
use path::Path;
26+
use ops::Drop;
2527
use ptr;
2628
use result;
2729
use str;

src/libcore/prelude.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ pub use tuple::{CopyableTuple, ImmutableTuple, ExtendedTupleOps};
4343
pub use vec::{CopyableVector, ImmutableVector};
4444
pub use vec::{ImmutableEqVector, ImmutableCopyableVector};
4545
pub use vec::{OwnedVector, OwnedCopyableVector};
46+
pub use io::{Reader, ReaderUtil, Writer, WriterUtil};
4647

4748
/* Reexported runtime types */
4849
pub use comm::{stream, Port, Chan, GenericChan, GenericSmartChan, GenericPort, Peekable};

src/librustdoc/markdown_pass.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ fn write_page(ctxt: &Ctxt, page: &doc::Page) {
127127
write_item_no_header(ctxt, doc);
128128
}
129129
}
130-
ctxt.w.write_done();
130+
ctxt.w.put_done();
131131
}
132132

133133
#[test]
@@ -146,8 +146,8 @@ fn should_request_new_writer_for_each_page() {
146146
}
147147

148148
fn write_title(ctxt: &Ctxt, page: doc::Page) {
149-
ctxt.w.write_line(fmt!("%% %s", make_title(page)));
150-
ctxt.w.write_line(~"");
149+
ctxt.w.put_line(fmt!("%% %s", make_title(page)));
150+
ctxt.w.put_line(~"");
151151
}
152152

153153
fn make_title(page: doc::Page) -> ~str {
@@ -198,8 +198,8 @@ fn write_header(ctxt: &Ctxt, lvl: Hlvl, doc: doc::ItemTag) {
198198
199199
fn write_header_(ctxt: &Ctxt, lvl: Hlvl, title: ~str) {
200200
let hashes = str::from_chars(vec::from_elem(lvl as uint, '#'));
201-
ctxt.w.write_line(fmt!("%s %s", hashes, title));
202-
ctxt.w.write_line(~"");
201+
ctxt.w.put_line(fmt!("%s %s", hashes, title));
202+
ctxt.w.put_line(~"");
203203
}
204204
205205
pub fn header_kind(doc: doc::ItemTag) -> ~str {
@@ -332,8 +332,8 @@ fn write_desc(
332332
) {
333333
match desc {
334334
Some(desc) => {
335-
ctxt.w.write_line(desc);
336-
ctxt.w.write_line(~"");
335+
ctxt.w.put_line(desc);
336+
ctxt.w.put_line(~"");
337337
}
338338
None => ()
339339
}
@@ -347,8 +347,8 @@ fn write_sections(ctxt: &Ctxt, sections: &[doc::Section]) {
347347

348348
fn write_section(ctxt: &Ctxt, section: doc::Section) {
349349
write_header_(ctxt, H4, copy section.header);
350-
ctxt.w.write_line(copy section.body);
351-
ctxt.w.write_line(~"");
350+
ctxt.w.put_line(copy section.body);
351+
ctxt.w.put_line(~"");
352352
}
353353

354354
#[test]
@@ -398,7 +398,7 @@ fn write_item_(ctxt: &Ctxt, doc: doc::ItemTag, write_header: bool) {
398398
doc::TraitTag(TraitDoc) => write_trait(ctxt, TraitDoc),
399399
doc::ImplTag(ImplDoc) => write_impl(ctxt, ImplDoc),
400400
doc::TyTag(TyDoc) => write_type(ctxt, TyDoc),
401-
doc::StructTag(StructDoc) => write_struct(ctxt, StructDoc),
401+
doc::StructTag(StructDoc) => put_struct(ctxt, StructDoc),
402402
}
403403
}
404404

@@ -428,13 +428,13 @@ fn write_index(ctxt: &Ctxt, index: doc::Index) {
428428
let header = header_text_(entry.kind, entry.name);
429429
let id = copy entry.link;
430430
if entry.brief.is_some() {
431-
ctxt.w.write_line(fmt!("* [%s](%s) - %s",
431+
ctxt.w.put_line(fmt!("* [%s](%s) - %s",
432432
header, id, (&entry.brief).get()));
433433
} else {
434-
ctxt.w.write_line(fmt!("* [%s](%s)", header, id));
434+
ctxt.w.put_line(fmt!("* [%s](%s)", header, id));
435435
}
436436
}
437-
ctxt.w.write_line(~"");
437+
ctxt.w.put_line(~"");
438438
}
439439
440440
#[test]
@@ -526,8 +526,8 @@ fn write_fnlike(
526526
fn write_sig(ctxt: &Ctxt, sig: Option<~str>) {
527527
match sig {
528528
Some(sig) => {
529-
ctxt.w.write_line(code_block_indent(sig));
530-
ctxt.w.write_line(~"");
529+
ctxt.w.put_line(code_block_indent(sig));
530+
ctxt.w.put_line(~"");
531531
}
532532
None => fail!(~"unimplemented")
533533
}
@@ -641,18 +641,18 @@ fn write_variants(
641641
write_variant(ctxt, copy *variant);
642642
}
643643
644-
ctxt.w.write_line(~"");
644+
ctxt.w.put_line(~"");
645645
}
646646
647647
fn write_variant(ctxt: &Ctxt, doc: doc::VariantDoc) {
648648
fail_unless!(doc.sig.is_some());
649649
let sig = (&doc.sig).get();
650650
match copy doc.desc {
651651
Some(desc) => {
652-
ctxt.w.write_line(fmt!("* `%s` - %s", sig, desc));
652+
ctxt.w.put_line(fmt!("* `%s` - %s", sig, desc));
653653
}
654654
None => {
655-
ctxt.w.write_line(fmt!("* `%s`", sig));
655+
ctxt.w.put_line(fmt!("* `%s`", sig));
656656
}
657657
}
658658
}
@@ -804,7 +804,7 @@ fn should_write_type_signature() {
804804
fail_unless!(str::contains(markdown, ~"\n\n type t = int\n\n"));
805805
}
806806

807-
fn write_struct(
807+
fn put_struct(
808808
ctxt: &Ctxt,
809809
doc: doc::StructDoc
810810
) {
@@ -813,7 +813,7 @@ fn write_struct(
813813
}
814814

815815
#[test]
816-
fn should_write_struct_header() {
816+
fn should_put_struct_header() {
817817
let markdown = test::render(~"struct S { field: () }");
818818
fail_unless!(str::contains(markdown, ~"## Struct `S`\n\n"));
819819
}

src/librustdoc/markdown_writer.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,21 @@ pub type Writer = ~fn(v: WriteInstr);
3434
pub type WriterFactory = ~fn(page: doc::Page) -> Writer;
3535

3636
pub trait WriterUtils {
37-
fn write_str(&self, +str: ~str);
38-
fn write_line(&self, +str: ~str);
39-
fn write_done(&self);
37+
fn put_str(&self, +str: ~str);
38+
fn put_line(&self, +str: ~str);
39+
fn put_done(&self);
4040
}
4141

4242
impl WriterUtils for Writer {
43-
fn write_str(&self, str: ~str) {
43+
fn put_str(&self, str: ~str) {
4444
(*self)(Write(str));
4545
}
4646

47-
fn write_line(&self, str: ~str) {
48-
self.write_str(str + ~"\n");
47+
fn put_line(&self, str: ~str) {
48+
self.put_str(str + ~"\n");
4949
}
5050

51-
fn write_done(&self) {
51+
fn put_done(&self) {
5252
(*self)(Done)
5353
}
5454
}

0 commit comments

Comments
 (0)