From b979d0323d287c1f8a199fafdb28dfb1a70f4d9c Mon Sep 17 00:00:00 2001 From: Anton Verinov Date: Sun, 15 Feb 2015 16:03:45 +0200 Subject: [PATCH] io reform update rust-lang/rfcs#517 --- Cargo.toml | 4 ++-- src/lib.rs | 15 +++++++++------ src/parser/mod.rs | 4 ++-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0f5de10f..12f270f3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,5 +14,5 @@ exclude = [ ] [dependencies] -regex_macros = "0.1.5" -regex = "0.1.10" +regex_macros = "0.1.8" +regex = "0.1.14" diff --git a/src/lib.rs b/src/lib.rs index bbba0c1b..5fce0783 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,12 +1,14 @@ #![crate_name = "markdown"] +#![feature(fs)] +#![feature(io)] #![feature(plugin)] -#[plugin] #[no_link] +#![plugin(regex_macros)] extern crate regex_macros; extern crate regex; -use std::io::File; -use std::io::IoError; +use std::fs::File; +use std::io::{Read, Error}; mod parser; mod html; @@ -18,14 +20,15 @@ pub fn to_html(text : &str) -> String{ html::to_html(&result) } -pub fn file_to_html(path : &Path) -> Result{ +pub fn file_to_html(path : &Path) -> Result{ let mut file = match File::open(path) { Ok(file) => file, Err(e) => return Err(e) }; - let text = match file.read_to_string() { - Ok(string) => string, + let mut text = String::new(); + match file.read_to_string(&mut text) { + Ok(()) => (), Err(e) => return Err(e) }; diff --git a/src/parser/mod.rs b/src/parser/mod.rs index 1e7c8086..ddf205ca 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -6,7 +6,7 @@ mod block; static SPLIT : Regex = regex!(r"\n(?:\s*\n|$)"); -#[derive(Show, PartialEq)] +#[derive(Debug, PartialEq)] pub enum Block { Header(Vec, usize), Paragraph(Vec), @@ -15,7 +15,7 @@ pub enum Block { Hr } -#[derive(Show, PartialEq)] +#[derive(Debug, PartialEq)] pub enum Span { Break, Text(String),