use-diagnostic-span 0.0.1

Generic diagnostic source and span primitives for RustUse
Documentation
  • Coverage
  • 100%
    23 out of 23 items documented1 out of 19 items with examples
  • Size
  • Source code size: 12.24 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 728.76 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 3s Average build duration of successful builds.
  • all releases: 3s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • RustUse/use-diagnostic
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • CloudBranch

use-diagnostic-span

Generic diagnostic source and span primitives for RustUse.

Foundation

use-diagnostic-span provides DiagnosticPosition, DiagnosticSourceId, and DiagnosticSpan for identifying source locations without assuming files, snippets, renderers, or terminal output.

Positions are 1-based. A span may include a source ID for a file, buffer, document, or virtual source, but source IDs are plain stable strings rather than filesystem-only paths.

Example

use use_diagnostic_span::{DiagnosticPosition, DiagnosticSourceId, DiagnosticSpan};

let source = DiagnosticSourceId::new("config.toml").unwrap();
let start = DiagnosticPosition::new(4, 9).unwrap();
let end = DiagnosticPosition::new(4, 16).unwrap();
let span = DiagnosticSpan::new(Some(source), start, end).unwrap();

assert_eq!(span.start().line(), 4);
assert!(span.source().is_some());

Scope

  • Positions use 1-based line and column numbers.
  • Spans validate that the end is not before the start.
  • Source IDs are generic stable strings.
  • File reading, snippet extraction, and source rendering are out of scope.

Status

use-diagnostic-span is a pre-1.0 crate with a deliberately small API.