[rust-dev] write_str error

Mic mictadlo at gmail.com
Sat Apr 7 20:58:35 PDT 2012


Hi,
I am getting the following errors:

$ rustc csv_create.rs
csv_create.rs:17:1: 17:14 error: attempted access of field write_str on
type core::io::writer, but no public field or method with that name was
found
csv_create.rs:17        rdr.write_str("aaa, bbb,ccc ,
ddd,eee,fff,ggg,hhh,iii,jjj,kkk,lll,mmm,nnn\n");
                                  ^~~~~~~~~~~~~
csv_create.rs:17:1: 17:78 error: mismatched types: expected function or
native function but found _|_
csv_create.rs:17        rdr.write_str("aaa, bbb,ccc ,
ddd,eee,fff,ggg,hhh,iii,jjj,kkk,lll,mmm,nnn\n");

^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

with the following code:

import io::reader_util;
import vec::map;

fn main(args: [str]) {

    let r = io::file_writer("csv.csv" , [io::create, io::truncate]); // r
is result<reader, err_str>
    if result::is_failure(r) {
        fail result::get_err(r);
    }

    let rdr = result::get(r);

    let count = 0;
    while true {

        if count == 4000000 { break; }
        rdr.write_str("aaa, bbb,ccc ,
ddd,eee,fff,ggg,hhh,iii,jjj,kkk,lll,mmm,nnn\n");
        count += 1;
    }
}

What did I do wrong and would it possible to rewrite the while loop with
for loop?

Thank you in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20120408/dae1a0eb/attachment.html>


More information about the Rust-dev mailing list