writer.rs
Contains an unbounded block loopSource uses a buffer write call
SHA-25625ff5ad6a8311d146a5b812024338b5b57a66266f861f92f2ff7376b56664c24
MaleculeH₂(DbF₂)
Evidence
1use std::error::FromError;
2use std::old_io as io;
3use std::str;
4
5use rustc_serialize::Encodable;
6
7use {
8 BorrowBytes, ByteString, CsvResult, Encoded, Error, RecordTerminator,
9 StrAllocating,
10};
11
12/// The quoting style to use when writing CSV data.
13#[derive(Copy)]
14pub enum QuoteStyle {
15 /// This puts quotes around every field. Always.
16 Always,
17 /// This puts quotes around fields only …
32/// This writer provides a convenient interface for encoding CSV data. While
33/// creating CSV data is much easier than parsing it, having a writer …
84:39… riter<io::IoResult<io::File>> {
85 Writer::from_writer(io::File::create(path))
86 }
87}
⋯5 lines
359:9… _bytes(&mut self, s: &[u8]) -> CsvResult<()> {
360 self.buf.write_all(s).map_err(Error::Io)
361 }
362
363 fn w_user_bytes(&mut self, s: &[u8]) -> CsvResult<()> {
364 if try!(self.should_quote(s)) { …
424:23… Vec::with_capacity(s.len() + 2);
425
426 buf.push(self.quote);
427 loop {
428 match s.position_elem(&self.quote) {
429 None => {
430 buf.extend(s.iter().map(|&x|x)); …