pub fn prefix_to_string<I: Iterator>(xs: I, max_len: usize) -> String where
    I::Item: Display
Expand description

Converts a prefix of an iterator to a string.

Suppose the iterator generates $(a, b, c, d)$. If max_len is 3, this function will return the string "[a, b, c, ...]". If max_len is 4 or more, this function will return [a, b, c, d].

This function will attempt to advance the iterator max_len + 1 times. The extra time is used determine whether the output string should contain an ellipsis.

Panics

Panics if max_len is 0.

Examples

extern crate itertools;

use itertools::Itertools;
use malachite_base::iterators::prefix_to_string;

assert_eq!(prefix_to_string(0..10, 3), "[0, 1, 2, ...]");
assert_eq!(prefix_to_string(0..4, 5), "[0, 1, 2, 3]");