pure_lines 0.2.0

A tool that beautify multiple lines
Documentation
  • Coverage
  • 100%
    3 out of 3 items documented1 out of 3 items with examples
  • Size
  • Source code size: 24.44 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 255.5 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 8s Average build duration of successful builds.
  • all releases: 8s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • maplepie/pure_lines
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • maplepie

pure_lines

A tool that beautify multiple lines.

  • Trim first line if empty
  • Trim min indent

Problem

What you need str:

hello
world

You had to do:

let s = "hello
world";
println!("{}",s);

Now you can:

let s = "
    hello
    world";
println!("{}",pure_lines::pure(s));

Example

Basic Example

use pure_lines;

fn main(){
    let a = "
    hello
    world";
    println!("==============");
    println!("before:");
    println!("{}",&a);
    println!("==============");
    let s = pure_lines::pure(a);
    println!("after:");
    println!("{}",s);
    println!("==============");

    // Output:
    // ==============
    // before:
    //
    //     hello
    //     world
    // ==============
    // after:
    // hello
    // world
    // ==============
}

Example with prefix

use pure_lines;

fn main(){
    let a = "
    hello
    world";
    println!("==============");
    println!("before:");
    println!("{}",&a);
    println!("==============");
    let s = pure_lines::pure_with(a,"> ");
    println!("after:");
    println!("{}",s);
    println!("==============");

    // Output:
    // ==============
    // before:
    //
    //     hello
    //     world
    // ==============
    // after:
    // > hello
    // > world
    // ==============
}

Advance

If you want your code more faster, using the quick feature. quick feature trim indent based on the first line which is not empty.

⚠Note: make sure the after lines indent must bigger than the first,or you will lose some string.

your Cargo.toml could look like this:

[dependencies]

pure_lines = { version = "0.2.0", features = ["quick"] }