fn eq()

in src/content/span.rs [42:62]


    fn eq(&self, other: &Self) -> bool {
        // this assumes single character content
        fn stylizations_eq(lhs: &Span, rhs: &Span) -> bool {
            let ignore_foreground_color = || lhs.is_padding() || rhs.is_padding();

            match (&lhs.stylization, &rhs.stylization) {
                (None, None) => true,
                (None, Some(other)) | (Some(other), None) => {
                    Span::is_unstyled(other, ignore_foreground_color())
                }
                (Some(lhs), Some(rhs)) => {
                    (lhs.foreground_color == rhs.foreground_color || ignore_foreground_color())
                        && lhs.background_color == rhs.background_color
                        && lhs.attributes == rhs.attributes
                }
            }
        }
        self.iter()
            .zip(other.iter())
            .all(|(lhs, rhs)| lhs.content == rhs.content && stylizations_eq(&lhs, &rhs))
    }