pure_lines 0.1.0

A tool that beautify multiple lines
Documentation

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
    // ==============
}