ratatui_toolkit/widgets/code_diff/foundation/diff_line/constructors/
removed.rs

1use crate::widgets::code_diff::diff_line::DiffLine;
2use crate::widgets::code_diff::enums::DiffLineKind;
3
4impl DiffLine {
5    /// Creates a removed diff line.
6    ///
7    /// Removed lines exist only in the old version of the file and are typically
8    /// displayed with a red background and a '-' prefix.
9    ///
10    /// # Arguments
11    ///
12    /// * `content` - The text content of the line
13    /// * `old_line_num` - Line number in the old version
14    ///
15    /// # Returns
16    ///
17    /// A new `DiffLine` with `DiffLineKind::Removed`
18    ///
19    /// # Example
20    ///
21    /// ```rust
22    /// use ratatui_toolkit::code_diff::{DiffLine, DiffLineKind};
23    ///
24    /// let line = DiffLine::removed("deleted line", 5);
25    /// assert!(matches!(line.kind, DiffLineKind::Removed));
26    /// assert!(line.new_line_num.is_none());
27    /// ```
28    pub fn removed(content: impl Into<String>, old_line_num: usize) -> Self {
29        Self {
30            kind: DiffLineKind::Removed,
31            content: content.into(),
32            old_line_num: Some(old_line_num),
33            new_line_num: None,
34        }
35    }
36}