pub fn compare(left_content: String, right_content: String) -> String {
    let left_lines: Vec<&str> = left_content.trim().split('\n').collect();
    let right_lines: Vec<&str> = right_content.trim().split('\n').collect();

    let max = max(&left_lines);
    let mut result = String::new();
    left_lines
        .iter()
        .zip(right_lines.iter())
        .for_each(|(left, right)| {
            let mut separator = '|';
            if left == right {
                separator = '=';
            }
            result += &format!("{:width$} {} {}\n", left, separator, right, width = max);
        });

    let left_len = left_lines.len();
    let right_len = right_lines.len();
    if left_len > right_len {
        for x in right_len..left_len {
            result += &format!("{:width$} |\n", left_lines[x], width = max);
        }
    } else if right_len > left_len {
        for x in left_len..right_len {
            result += &format!("{:width$} | {}\n", "", right_lines[x], width = max);
        }
    }

    result
}
/// Compares two strings line by line.
/// Matching lines are shown with =
/// Non-matching lines are shown with |
/// ```
/// use ldiff::compare;
/// let left = "asdf".to_string();
/// let right = "asdf".to_string();
/// let expected = "asdf = asdf\n".to_string();
/// let result = compare(left, right);
///
/// assert_eq!(expected, result);
/// ```
Compares two strings line by line.


Compares two strings line by line .
pub fn compare(left_content: String, right_content: String) -> String {
    let left_lines: Vec<&str> = left_content.trim().split('\n').collect();
    let right_lines: Vec<&str> = right_content.trim().split('\n').collect();
    let max = max(&left_lines);
    let mut result = String::new();
    left_lines
        .iter()
        .zip(right_lines.iter())
        .for_each(|(left, right)| {
            let mut separator = '|';
            if left == right {
                separator = '=';
            }
            result += &format!("{:width$} {} {}\n", left, separator, right, width = max);
        });
    let left_len = left_lines.len();
    let right_len = right_lines.len();
    if left_len > right_len {
        for x in right_len..left_len {
            result += &format!("{:width$} |\n", left_lines[x], width = max);
        }
    } else if right_len > left_len {
        for x in left_len..right_len {
            result += &format!("{:width$} | {}\n", "", right_lines[x], width = max);
        }
    }
    result
}
pub fn compare ( left_content : String , right_content : String ) -> String { let left_lines : Vec < & str > = left_content . trim ( ) . split ( '\n' ) . collect ( ) ; let right_lines : Vec < & str > = right_content . trim ( ) . split ( '\n' ) . collect ( ) ; let max = max ( & left_lines ) ; let mut result = String :: new ( ) ; left_lines . iter ( ) . zip ( right_lines . iter ( ) ) . for_each ( | ( left , right ) | { let mut separator = '|' ; if left == right { separator = '=' ; } result += & format ! ( " \n " left separator right width max ) ; } ) ; let left_len = left_lines . len ( ) ; let right_len = right_lines . len ( ) ; if left_len > right_len { for x in right_len .. left_len { result += & format ! ( " \n " left_lines [ x ] width max ) ; } } else if right_len > left_len { for x in left_len .. right_len { result += & format ! ( " \n " " " right_lines [ x ] width max ) ; } } result }
Compares two strings line by line.
Compares two strings line by line .
left_content
String
right_content
String