Crates.io | pure_lines |
lib.rs | pure_lines |
version | 0.2.0 |
source | src |
created_at | 2021-11-04 17:07:41.538003 |
updated_at | 2021-11-05 16:20:36.966 |
description | A tool that beautify multiple lines |
homepage | |
repository | https://github.com/maplepie/pure_lines |
max_upload_size | |
id | 476748 |
size | 24,442 |
A tool that beautify multiple lines.
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));
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
// ==============
}
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
// ==============
}
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"] }