<commit_before>//! Prelude

use std::ops::FnMut;

use futures::stream;

pub use command::Response;
pub use futures::Future;
pub use futures::stream::Stream;
pub use serde_json::{Value, from_str, to_string};

pub trait Consumer {
    fn consume(self);
}

macro_rules! consume {
    () => {
        fn consume(self) {
            for _ in self.wait() { }
        }
    }
}

impl<T> Consumer for Response<T> { consume!{} }
impl<S, F> Consumer for stream::ForEach<S, F>
    where S: Stream, F: FnMut(S::Item) -> Result<(), S::Error>
{ consume!{} }<commit_msg>Cleanup the prelude<commit_after>//! Prelude

pub use command::Response;
pub use futures::Future;
pub use futures::stream::Stream;
pub use serde_json::{Value, from_str, to_string};

// Consumers to make blocking more convenient
//
// Ideally we would want to use just one trait `Consumer`.
// However, the implementations for `T: Stream` and `T: Future`
// would clash.

/// Block the current thread until we have received all the results from
/// the stream.
pub trait StreamConsumer {
    fn consume(self);
}

/// Block the current thread until we have received all the results from
/// the future.
pub trait FutureConsumer {
    fn consume(self);
}

macro_rules! consume {
    () => {
        fn consume(self) {
            for _ in self.wait() { }
        }
    }
}

impl<T: Stream> StreamConsumer for T { consume!{} }
impl<T: Future> FutureConsumer for T { consume!{} }
{'fraction_non_alphanumeric': 0.1371588523442967, 'fraction_numerical': 0.0, 'mean_word_length': 3.3202416918429005, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6150043', 'n_tokens_mistral': 460, 'n_tokens_neox': 445, 'n_words': 153}