Skip to main content

DisplaySliceExt

Trait DisplaySliceExt 

Source
pub trait DisplaySliceExt<'a, T: Display> {
    // Required method
    fn display(&'a self) -> DisplaySlice<'a, T>;

    // Provided method
    fn display_n(&'a self, n: usize) -> DisplaySlice<'a, T> { ... }
}
Expand description

Implement Display for &[T] if T is Display.

It outputs at most MAX elements, excluding those from the 5th to the second-to-last one:

  • DisplaySlice(&[1,2,3,4,5,6]) outputs: "[1,2,3,4,...,6]".

§Example

use display_more::DisplaySliceExt;

let a = vec![1, 2, 3, 4, 5, 6];
assert_eq!(a.display().to_string(), "[1,2,3,4,..,6]");

Required Methods§

Source

fn display(&'a self) -> DisplaySlice<'a, T>

Provided Methods§

Source

fn display_n(&'a self, n: usize) -> DisplaySlice<'a, T>

Display at most n elements.

Implementations on Foreign Types§

Source§

impl<T> DisplaySliceExt<'_, T> for [T]
where T: Display,

Source§

fn display(&self) -> DisplaySlice<'_, T>

Implementors§