#indent #string #byte-slice

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 95/week @ 2024-06-17 180/week @ 2024-06-24 155/week @ 2024-07-01 200/week @ 2024-07-08 283/week @ 2024-07-15 402/week @ 2024-07-22 346/week @ 2024-07-29 370/week @ 2024-08-05 299/week @ 2024-08-12 87/week @ 2024-08-19 143/week @ 2024-08-26 173/week @ 2024-09-02 98/week @ 2024-09-09 44/week @ 2024-09-16 170/week @ 2024-09-23 74/week @ 2024-09-30

391 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