#indent #byte-slice #string

indented_text_writer

A simple IndentedTextWriter

5 releases (3 breaking)

0.4.0 Jan 24, 2024
0.3.0 Dec 16, 2023
0.2.0 Mar 16, 2023
0.1.1 Dec 24, 2022
0.1.0 Nov 25, 2022

#5 in #indent

Download history 405/week @ 2024-07-21 357/week @ 2024-07-28 335/week @ 2024-08-04 335/week @ 2024-08-11 84/week @ 2024-08-18 144/week @ 2024-08-25 171/week @ 2024-09-01 101/week @ 2024-09-08 44/week @ 2024-09-15 166/week @ 2024-09-22 71/week @ 2024-09-29 90/week @ 2024-10-06 107/week @ 2024-10-13 105/week @ 2024-10-20 127/week @ 2024-10-27 123/week @ 2024-11-03

465 downloads per month

MIT license

11KB
158 lines

This crate is a indented_text_writer type allowing you to append anything that satisfies the ToBytes trait to it. This includes things such as string slices, owned strings, byte slices, and characters for example.

like : C#

Example

write code:

#[cfg(test)]
use super::IndentedTextWriter;

fn main() {
   let is_lf = true;
    let mut writer = IndentedTextWriter::new("    ",1024, '{', '}', is_lf);
    writer.write_line("struct Data {");
    writer.write_line("name: String,");
    writer.write_line("value: i32");
    writer.write_line("}");
    println!("{}",writer.string().unwrap());
}

Result:

struct Data {
    name: String,
    value: i32
}

forked by https://github.com/gsquire/string-builder

License

MIT

No runtime deps