Function zero_copy_pads::align_center_left[][src]

pub fn align_center_left<Value: Width>(
    value: Value,
    total_width: usize
) -> PaddedValue<Value, char, IgnoreExcess, AlignCenterLeft>

Pad space characters both side of a value with the remainder block (if any) in the right.

When value.width() is not greater than total_width and total_width - value.width() is an even number, center the value in a space of total_width:

use zero_copy_pads::align_center_left;
let value = "abc";
let padded_value = align_center_left(value, 7);
assert_eq!(padded_value.to_string(), "  abc  ");

When value.width() is not greater than total_width and total_width - value.width() is an odd number center the value in a space of total_width but with 1 remainder block to the right:

use zero_copy_pads::align_center_left;
let value = "abc";
let padded_value = align_center_left(value, 8);
assert_eq!(padded_value.to_string(), "  abc   ");

When value.width() is greater than total_width, display value as is:

use zero_copy_pads::align_center_left;
let value = "abcdefghi";
let padded_value = align_center_left(value, 5);
assert_eq!(padded_value.to_string(), value);