7 releases

Uses old Rust 2015

0.3.2 Jul 17, 2018
0.3.1 Jan 25, 2018
0.3.0 Dec 31, 2017
0.2.4 Dec 27, 2017

#1434 in Text processing

Download history 16/week @ 2024-02-19 13/week @ 2024-02-26 6/week @ 2024-03-04 20/week @ 2024-03-11

55 downloads per month
Used in 2 crates

MIT license

12KB
284 lines

blockcounter

Version info Build Status Build status

Count blocks in a text.

Example

extern crate blockcounter;
use blockcounter::{count_blocks, Blocks, clean};

fn main() {
    let text = "0\n1\n\n2\n\n\n3\n\n".to_string();
    println!("{}", text);
    println!("===========");
    println!("text has {} blocks.", count_blocks(2, text.as_bytes()));
    println!("======================");
    println!("");
    
    for block in Blocks::new(2, text.as_bytes()) {
        print!("{}", clean(&block));
        println!("=============");
    }
}

lib.rs:

A crate to count blocks in plain text.

Consider a block a set of lines separated by a given number of empty lines.

Example

extern crate blockcounter;
use blockcounter::{count_blocks, Blocks, clean};

fn main() {
let text = "0\n1\n\n2\n\n\n3\n\n".to_string();
println!("{}", text);
println!("===========");
println!("text has {} blocks.", count_blocks(2, text.as_bytes()));
println!("======================");
println!("");

for block in Blocks::new(2, text.as_bytes()) {
print!("{}", clean(&block));
println!("=============");
}
}

No runtime deps