pub fn diagnostic_at_byte(
diagnostics: &[Diagnostic],
byte: usize,
) -> Option<DiagnosticHit>Expand description
Returns the first diagnostic whose inclusive range contains byte.
Both start and end are inclusive, unlike standard Rust ranges; overlapping
diagnostics select lowest slice index. No match returns None.
ยงExamples
use ailloli_ui_editor::{code::diagnostic_at_byte, Diagnostic, DiagnosticSeverity};
let diagnostics = [Diagnostic::new(2..4, DiagnosticSeverity::Error, "bad")];
assert_eq!(diagnostic_at_byte(&diagnostics, 4).unwrap().index, 0);
assert!(diagnostic_at_byte(&diagnostics, 5).is_none());