Skip to content

Commit ca95e77

Browse files
committed
smallest changes (I could find) to fix
Before fix, errors were -*- mode: compilation; default-directory: "~/gitwk-github/markdown-chapterise/" -*- Compilation started at Thu Jul 16 19:44:10 cd ~/gitwk-github/markdown-chapterise/ && make /Users/mca/Applications/rust-1.0.0/bin/cargo test Compiling markdown-chapterise v0.0.1 (file:///Users/mca/gitwk-github/markdown-chapterise) src/mdstream.rs:29:9: 29:61 error: mismatched types: expected `mdstream::MarkdownStream<T>`, found `mdstream::MarkdownStream<core::iter::Iterator<Item=collections::string::String>>` (expected type parameter, found trait core::iter::Iterator) [E0308] src/mdstream.rs:29 MarkdownStream { input: Box::new(lines.peekable()) } ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/mdstream.rs:29:9: 29:61 error: the trait `core::marker::Sized` is not implemented for the type `core::iter::Iterator<Item=collections::string::String>` [E0277] src/mdstream.rs:29 MarkdownStream { input: Box::new(lines.peekable()) } ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/mdstream.rs:29:9: 29:61 note: `core::iter::Iterator<Item=collections::string::String>` does not have a constant size known at compile-time src/mdstream.rs:29 MarkdownStream { input: Box::new(lines.peekable()) } ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/mdstream.rs:66:10: 66:14 error: mismatched types: expected `collections::vec::Vec<collections::string::String>`, found `collections::vec::Vec<&str>` (expected struct `collections::string::String`, found &-ptr) [E0308] src/mdstream.rs:66 (v_cp, out) ^~~~ src/mdstream.rs:66:16: 66:19 error: mismatched types: expected `core::slice::Iter<'_, collections::string::String>`, found `collections::vec::Vec<collections::string::String>` (expected struct `core::slice::Iter`, found struct `collections::vec::Vec`) [E0308] src/mdstream.rs:66 (v_cp, out) ^~~ src/mdstream.rs:72:37: 72:38 error: mismatched types: expected `Box<_>`, found `core::slice::Iter<'_, collections::string::String>` (expected box, found struct `core::slice::Iter`) [E0308] src/mdstream.rs:72 let m = MarkdownStream::new(i); ^ error: aborting due to 5 previous errors Could not compile `markdown-chapterise`. To learn more, run the command again with --verbose. make: *** [build] Error 101 Compilation exited abnormally with code 2 at Thu Jul 16 19:44:11 After fix, warnings remain -*- mode: compilation; default-directory: "~/gitwk-github/markdown-chapterise/" -*- Compilation started at Thu Jul 16 18:01:12 cd ~/gitwk-github/markdown-chapterise/ && make /Users/mca/Applications/rust-1.0.0/bin/cargo test Compiling markdown-chapterise v0.0.1 (file:///Users/mca/gitwk-github/markdown-chapterise) src/mdout.rs:9:1: 20:2 warning: struct is never used: `MarkdownOut`, #[warn(dead_code)] on by default src/mdout.rs:9 pub struct MarkdownOut { src/mdout.rs:10 /// Directory into which we write src/mdout.rs:11 outdir: PathBuf, src/mdout.rs:12 /// Serial number prefix for output files src/mdout.rs:13 filenum: u32, src/mdout.rs:14 /// Final name for the File after closing ... src/mdout.rs:11:5: 11:20 warning: struct field is never used: `outdir`, #[warn(dead_code)] on by default src/mdout.rs:11 outdir: PathBuf, ^~~~~~~~~~~~~~~ src/mdout.rs:13:5: 13:17 warning: struct field is never used: `filenum`, #[warn(dead_code)] on by default src/mdout.rs:13 filenum: u32, ^~~~~~~~~~~~ src/mdout.rs:15:9: 15:25 warning: struct field is never used: `outpath`, #[warn(dead_code)] on by default src/mdout.rs:15 pub outpath: PathBuf, ^~~~~~~~~~~~~~~~ src/mdout.rs:17:5: 17:21 warning: struct field is never used: `tmppath`, #[warn(dead_code)] on by default src/mdout.rs:17 tmppath: PathBuf, ^~~~~~~~~~~~~~~~ src/mdout.rs:19:5: 19:33 warning: struct field is never used: `outfh`, #[warn(dead_code)] on by default src/mdout.rs:19 outfh: RefCell<Option<File>>, // XXX: mutability needed to close File, better way? ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/mdout.rs:24:5: 26:6 warning: method is never used: `new`, #[warn(dead_code)] on by default src/mdout.rs:24 pub fn new(outdir: &Path, leafname: &str) -> Result<MarkdownOut> { src/mdout.rs:25 _new(outdir.to_path_buf(), 0, leafname) src/mdout.rs:26 } src/mdout.rs:27:5: 34:6 warning: method is never used: `append`, #[warn(dead_code)] on by default src/mdout.rs:27 pub fn append(&self, data: String) -> Result<()> { src/mdout.rs:28 let mut fhput = self.outfh.borrow_mut(); src/mdout.rs:29 match (*fhput).iter_mut().next() { src/mdout.rs:30 Some(&mut ref mut f) => // XXX: &mut ref mut ?! src/mdout.rs:31 writeln!(f, "{}", data), src/mdout.rs:32 None => self.gone(), ... src/mdout.rs:35:5: 38:6 warning: method is never used: `next`, #[warn(dead_code)] on by default src/mdout.rs:35 pub fn next(self, leafname: &str) -> Result<MarkdownOut> { src/mdout.rs:36 let n = self.filenum + 1; src/mdout.rs:37 _new(self.outdir, n, leafname) src/mdout.rs:38 } src/mdout.rs:39:5: 48:6 warning: method is never used: `close`, #[warn(dead_code)] on by default src/mdout.rs:39 pub fn close(&self) -> Result<()> { src/mdout.rs:40 let mut fhput = self.outfh.borrow_mut(); src/mdout.rs:41 match *fhput { src/mdout.rs:42 Some(_) => { src/mdout.rs:43 *fhput = None; src/mdout.rs:44 rename(self.tmppath.as_path(), self.outpath.as_path()) ... src/mdout.rs:49:5: 52:6 warning: method is never used: `gone`, #[warn(dead_code)] on by default src/mdout.rs:49 fn gone(&self) -> Result<()> { src/mdout.rs:50 let msg = "File was already closed and renamed"; src/mdout.rs:51 Err( Error::new(ErrorKind::AlreadyExists, msg) ) src/mdout.rs:52 } src/mdout.rs:70:1: 79:2 warning: function is never used: `mkout`, #[warn(dead_code)] on by default src/mdout.rs:70 fn mkout(outdir: &PathBuf, filenum: u32, leafname: &str, is_tmp: bool) -> PathBuf { src/mdout.rs:71 let mut outpath = outdir.clone(); src/mdout.rs:72 let sfx = if is_tmp { src/mdout.rs:73 "+" // XXX: insecure tmpfile. tmpnam is unstable & libc; rand is elsewhere src/mdout.rs:74 } else { src/mdout.rs:75 "" ... src/mdstream.rs:1:5: 1:23 warning: unused import, #[warn(unused_imports)] on by default src/mdstream.rs:1 use std::cell::RefCell; ^~~~~~~~~~~~~~~~~~ src/mdstream.rs:5:5: 5:25 warning: unused import, #[warn(unused_imports)] on by default src/mdstream.rs:5 use std::iter::FilterMap; ^~~~~~~~~~~~~~~~~~~~ src/mdstream.rs:6:5: 6:19 warning: unused import, #[warn(unused_imports)] on by default src/mdstream.rs:6 use std::io::Lines; ^~~~~~~~~~~~~~ src/mdstream.rs:7:5: 7:23 warning: unused import, #[warn(unused_imports)] on by default src/mdstream.rs:7 use std::io::BufReader; ^~~~~~~~~~~~~~~~~~ src/mdstream.rs:8:5: 8:18 warning: unused import, #[warn(unused_imports)] on by default src/mdstream.rs:8 use std::fs::File; ^~~~~~~~~~~~~ src/mdstream.rs:19:1: 21:2 warning: function is never used: `io_unwrap`, #[warn(dead_code)] on by default src/mdstream.rs:19 fn io_unwrap(result: Result<String>) -> Option<String> { src/mdstream.rs:20 result.ok() src/mdstream.rs:21 } src/mdstream.rs:25:5: 31:6 warning: method is never used: `new_io`, #[warn(dead_code)] on by default src/mdstream.rs:25 pub fn new_io(lines: Box<Iterator<Item=Result<String>>>) -> MarkdownStream src/mdstream.rs:26 { src/mdstream.rs:27 let lines: Box<Iterator<Item=String>> = src/mdstream.rs:28 Box::new(lines.filter_map(io_unwrap)); src/mdstream.rs:29 MarkdownStream { input: Box::new(lines.peekable()) } src/mdstream.rs:30 // three boxes, hmm ... src/mdstream.rs:61:13: 61:17 warning: unused variable: `v_cp`, #[warn(unused_variables)] on by default src/mdstream.rs:61 let v_cp = input.clone(); ^~~~ src/main.rs:19:1: 35:2 warning: function is never used: `main`, #[warn(dead_code)] on by default src/main.rs:19 fn main() { src/main.rs:20 let mut args = env::args(); src/main.rs:21 let prog = args.next().expect("no $0 ?"); src/main.rs:22 let infile = args.next().expect(& format!("Syntax: {} <input.md> [ <outdir> ]", prog)); src/main.rs:23 let dir = args.next(); src/main.rs:24 let outdir = match dir { ... src/main.rs:37:1: 56:2 warning: function is never used: `do_split`, #[warn(dead_code)] on by default src/main.rs:37 fn do_split(input: BufReader<File>, outdir: &Path, split_depth: u32) { src/main.rs:38 let lines = input.lines(); src/main.rs:39 let mut output = showerror("create", MarkdownOut::new(outdir, "prelude")); src/main.rs:40 // let lines = lines.filter_map(|result| result.ok()); src/main.rs:41 // for ele in MarkdownStream::new(Box::new(lines)) { src/main.rs:42 for ele in MarkdownStream::new_io(Box::new(lines)) { ... src/main.rs:75:9: 75:12 warning: unused variable: `obj`, #[warn(unused_variables)] on by default src/main.rs:75 let obj = "bar"; ^~~ Running target/debug/markdown_chapterise-cc4f9044e36b23f2 running 5 tests test mdslurp::othercheck ... ok test mdstream::tests::t_vec_others ... ok test t_showerror_err ... ok test mdslurp::headcheck ... ok test t_showerror_ok ... ok test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured /Users/mca/Applications/rust-1.0.0/bin/cargo build Compiling markdown-chapterise v0.0.1 (file:///Users/mca/gitwk-github/markdown-chapterise) src/mdstream.rs:1:5: 1:23 warning: unused import, #[warn(unused_imports)] on by default src/mdstream.rs:1 use std::cell::RefCell; ^~~~~~~~~~~~~~~~~~ src/mdstream.rs:5:5: 5:25 warning: unused import, #[warn(unused_imports)] on by default src/mdstream.rs:5 use std::iter::FilterMap; ^~~~~~~~~~~~~~~~~~~~ src/mdstream.rs:6:5: 6:19 warning: unused import, #[warn(unused_imports)] on by default src/mdstream.rs:6 use std::io::Lines; ^~~~~~~~~~~~~~ src/mdstream.rs:7:5: 7:23 warning: unused import, #[warn(unused_imports)] on by default src/mdstream.rs:7 use std::io::BufReader; ^~~~~~~~~~~~~~~~~~ src/mdstream.rs:8:5: 8:18 warning: unused import, #[warn(unused_imports)] on by default src/mdstream.rs:8 use std::fs::File; ^~~~~~~~~~~~~ src/mdstream.rs:32:5: 36:6 warning: method is never used: `new`, #[warn(dead_code)] on by default src/mdstream.rs:32 pub fn new(lines: Box<Iterator<Item=String>>) -> MarkdownStream src/mdstream.rs:33 { src/mdstream.rs:34 let lines = lines.peekable(); src/mdstream.rs:35 MarkdownStream { input: Box::new(lines) } src/mdstream.rs:36 } Compilation finished at Thu Jul 16 18:01:19
1 parent 5b48c72 commit ca95e77

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/mdstream.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,24 @@ use std::io::Result;
1212
use mdslurp::MarkdownEle;
1313

1414

15-
pub struct MarkdownStream<T: Iterator<Item=String>> {
16-
input: Box<Peekable<Box<T>>>,
15+
pub struct MarkdownStream {
16+
input: Box<Peekable<Box<Iterator<Item=String>>>>,
1717
}
1818

1919
fn io_unwrap(result: Result<String>) -> Option<String> {
2020
result.ok()
2121
}
2222

23-
impl<T: Iterator<Item=String>> MarkdownStream<T> {
24-
// pub fn new_io<IoT: Iterator<Item=Result<String>>>(lines: Box<IoT>) -> MarkdownStream<T>
25-
pub fn new_io(lines: Box<Iterator<Item=Result<String>>>) -> MarkdownStream<T>
23+
impl MarkdownStream {
24+
// pub fn new_io<IoT: Iterator<Item=Result<String>>>(lines: Box<IoT>) -> MarkdownStream
25+
pub fn new_io(lines: Box<Iterator<Item=Result<String>>>) -> MarkdownStream
2626
{
2727
let lines: Box<Iterator<Item=String>> =
2828
Box::new(lines.filter_map(io_unwrap));
2929
MarkdownStream { input: Box::new(lines.peekable()) }
3030
// three boxes, hmm
3131
}
32-
pub fn new(lines: Box<T>) -> MarkdownStream<T>
32+
pub fn new(lines: Box<Iterator<Item=String>>) -> MarkdownStream
3333
{
3434
let lines = lines.peekable();
3535
MarkdownStream { input: Box::new(lines) }
@@ -38,7 +38,7 @@ impl<T: Iterator<Item=String>> MarkdownStream<T> {
3838

3939
// iterator howto - thanks http://rustbyexample.com/trait/iter.html
4040

41-
impl<T: Iterator<Item=String>> Iterator for MarkdownStream<T> {
41+
impl Iterator for MarkdownStream {
4242
type Item = MarkdownEle;
4343
fn next(&mut self) -> Option<MarkdownEle> {
4444
let mut lines = self.input.deref_mut();
@@ -55,21 +55,21 @@ impl<T: Iterator<Item=String>> Iterator for MarkdownStream<T> {
5555
mod tests {
5656
use super::MarkdownStream;
5757
use mdslurp::MarkdownEle;
58-
use std::slice::Iter;
58+
use std::vec::IntoIter;
5959

60-
fn stringvec(input: Vec<&str>) -> (Vec<String>, Iter<String>) {
60+
fn stringvec(input: Vec<&str>) -> (Vec<String>, IntoIter<String>) {
6161
let v_cp = input.clone();
6262
let out: Vec<String> = input
6363
.into_iter()
64-
.map(|s| String::from_str(s) + "\n")
64+
.map(|s| s.to_string() + "\n")
6565
.collect::<Vec<String>>();
66-
(v_cp, out)
66+
(out.clone(), out.into_iter())
6767
}
6868

6969
#[test]
7070
fn t_vec_others() {
7171
let (v, i) = stringvec(vec!("Hello", "world"));
72-
let m = MarkdownStream::new(i);
73-
assert_eq!(m.next(), Some(MarkdownEle::Other { txt: v[0] }));
72+
let mut m = MarkdownStream::new(Box::new(i));
73+
assert_eq!(m.next(), Some(MarkdownEle::Other { txt: v[0].to_owned() }));
7474
}
7575
}

0 commit comments

Comments
 (0)