acorn_diff/unified/mod.rs
1use alloc::string::{String, ToString};
2use similar::TextDiff;
3
4/// Creates a unified line diff with three lines of context.
5#[must_use]
6pub fn unified_diff(before: &str, after: &str, before_label: &str, after_label: &str) -> String {
7 TextDiff::from_lines(before, after)
8 .unified_diff()
9 .context_radius(3)
10 .header(before_label, after_label)
11 .to_string()
12}
13
14#[cfg(test)]
15mod tests;