[][src]Struct sise::CompactStringWriter

pub struct CompactStringWriter<'a> { /* fields omitted */ }

Writer that writes everything into a single line string.

Example

use sise::Writer as _;

let mut result = String::new();
let mut writer = sise::CompactStringWriter::new(&mut result);

writer.begin_list(&sise::VoidWriterOptions).unwrap();
writer.write_atom("example", &sise::VoidWriterOptions).unwrap();
writer.begin_list(&sise::VoidWriterOptions).unwrap();
// Write the three atoms in a single line.
writer.write_atom("1", &sise::VoidWriterOptions).unwrap();
writer.write_atom("2", &sise::VoidWriterOptions).unwrap();
writer.write_atom("3", &sise::VoidWriterOptions).unwrap();
writer.end_list(&sise::VoidWriterOptions).unwrap();
writer.begin_list(&sise::VoidWriterOptions).unwrap();
// Write the three atoms in a single line.
writer.write_atom("a", &sise::VoidWriterOptions).unwrap();
writer.write_atom("b", &sise::VoidWriterOptions).unwrap();
writer.write_atom("c", &sise::VoidWriterOptions).unwrap();
writer.end_list(&sise::VoidWriterOptions).unwrap();
writer.end_list(&sise::VoidWriterOptions).unwrap();
writer.finish(&sise::VoidWriterOptions);

let expected_result = "(example (1 2 3) (a b c))";
assert_eq!(result, expected_result);

Methods

impl<'a> CompactStringWriter<'a>[src]

pub fn new(dst: &'a mut String) -> Self[src]

Trait Implementations

impl<'a> Writer for CompactStringWriter<'a>[src]

type Result = ()

Type of data returned by the writer.

type Error = Infallible

The error type that may be produced while writing.

type AtomOptions = VoidWriterOptions

Type of options that can be passed to write_atom.

type BeginListOptions = VoidWriterOptions

Type of options that can be passed to begin_list.

type EndListOptions = VoidWriterOptions

Type of options that can be passed to end_list.

type FinishOptions = VoidWriterOptions

Type of options that can be passed to finish.

Auto Trait Implementations

impl<'a> Send for CompactStringWriter<'a>

impl<'a> Sync for CompactStringWriter<'a>

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]