Function cut_right_whitespace_with_tabstops

Source
pub fn cut_right_whitespace_with_tabstops(
    source: &str,
    indent: i32,
) -> Cow<'_, str>
Expand description

Returns trailing whitespace with total length of indent.

Input: a string of characters (presumed whitespaces, can be anything), where each one of them contributes 1 to indent (except for tabs, whose width may vary with tabstop = 4).

If an indent splits a tab, that tab is replaced with 4 spaces.

Example: cut_right_whitespace_with_tabstops(“\t\t”, 6) would return “ \t“ (two preceding spaces) because first tab gets expanded to 6 spaces.

assert_eq!(cut_right_whitespace_with_tabstops("\t\t", 6), "  \t");