truncate-slice-debug

Crates.iotruncate-slice-debug
lib.rstruncate-slice-debug
version0.1.1
sourcesrc
created_at2022-08-10 22:06:29.304849
updated_at2022-10-05 18:19:40.333167
descriptionExtension for slices to truncate debug output to a set limit of items
homepagehttps://github.com/thepacketgeek/truncate-slice-debug
repositoryhttps://github.com/thepacketgeek/truncate-slice-debug
max_upload_size
id642929
size15,780
Mat Wood (thepacketgeek)

documentation

https://docs.rs/truncate-slice-debug

README

truncate-slice-debug

A helper trait to truncate slice Debug output to a provided limit of items.

Example Usage

use truncate_slice_debug::TruncateSliceDebug;

fn main() {
    let values = vec![0, 1, 2, 3, 4, 5];

    let dbg_output = format!("{:?}", values.as_slice().truncate_debug(3));
    assert_eq!(&dbg_output, "[0, 1, 2, ...(3 more)]");

    let dbg_output = format!("{:?}", values.as_slice().truncate_debug(10));
    assert_eq!(&dbg_output, "[0, 1, 2, 3, 4, 5]");
}

License

truncate-slice-debug is both MIT and Apache License, Version 2.0 licensed, as found in the LICENSE-MIT and LICENSE-APACHE files.

Commit count: 2

cargo fmt