debug_iterator

Crates.iodebug_iterator
lib.rsdebug_iterator
version0.1.0
sourcesrc
created_at2019-07-25 03:46:53.844393
updated_at2019-07-25 03:46:53.844393
descriptiona simple iterator adapter that prints out the debug repr. of the item
homepage
repositoryhttps://github.com/museun/debug_iterator
max_upload_size
id151478
size8,293
(museun)

documentation

README

debug_iterator

debug_iterator

This is a simple iterator adapter thats is applicable to iterators where the Iterator::Item is std::fmt::Debug

It prints to stderr by default, but using the feature 'logging' prints out to the log crate facade.

use debug_iterator::DebugIterator as _;

#[derive(Debug)]
struct Person {
    name: String,
    age: i32
}

let everyone_is_named_bob = "Bob".to_string();
let iter = (1..=3)
    .map(|k| k * 4)
    .map(|age| Person {
        name: everyone_is_named_bob.clone(),
        age,
    })
    .clone();

// debug ("{:?}")
iter.debug().for_each(|_| ());
// Person { name: "Bob", age: 4 }
// Person { name: "Bob", age: 8 }
// Person { name: "Bob", age: 12 }

// debug_pretty ("{:#?}")
iter.debug_pretty().for_each(|_| ());
// Person {
//     name: "Bob",
//     age: 4,
// }
// Person {
//     name: "Bob",
//     age: 8,
// }
// Person {
//     name: "Bob",
//     age: 12,
// }

// '{:?}' with a `&str` prefix:
iter.debug_prefix("This person is").for_each(|_| ());
// This person is: Person { name: "Bob", age: 4 }
// This person is: Person { name: "Bob", age: 8 }
// This person is: Person { name: "Bob", age: 12 }

// '{:#?}' with a `&str` prefix:
iter.debug_prefix_pretty("This person is").for_each(|_| ());
// This person is: Person {
//     name: "Bob",
//     age: 4,
// }
// This person is: Person {
//     name: "Bob",
//     age: 8,
// }
// This person is: Person {
//     name: "Bob",
//     age: 12,
// }

License: 0BSD

Commit count: 3

cargo fmt