pub struct Writer<W> { /* private fields */ }
Expand description
A writer for CoNLL-U sentences.
This writer will write sentences to the embedded writer in CoNLL-U tabular format.
Implementations
sourceimpl<W: Write> Writer<W>
impl<W: Write> Writer<W>
sourcepub fn new(write: W) -> Writer<W>
pub fn new(write: W) -> Writer<W>
Construct a new writer from an object that implements the
Write
trait.
sourcepub fn get_ref(&self) -> &W
pub fn get_ref(&self) -> &W
Borrow the embedded writer. Getting the underlying writer is often useful when the writer writes to a memory object.
Examples
use std::str;
use conllu::io::{Writer, WriteSentence};
use udgraph::graph::Sentence;
use udgraph::token::Token;
let output = Vec::new();
let mut writer = Writer::new(output);
let mut sent = Sentence::new();
sent.push(Token::new("hello"));
sent.push(Token::new("world"));
writer.write_sentence(&sent).unwrap();
println!("Output:\n{}", str::from_utf8(writer.get_ref()).unwrap());
Trait Implementations
Auto Trait Implementations
impl<W> RefUnwindSafe for Writer<W> where
W: RefUnwindSafe,
impl<W> Send for Writer<W> where
W: Send,
impl<W> Sync for Writer<W> where
W: Sync,
impl<W> Unpin for Writer<W> where
W: Unpin,
impl<W> UnwindSafe for Writer<W> where
W: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more