diff --git a/README.md b/README.md index 35ff4ed..bd0b598 100644 --- a/README.md +++ b/README.md @@ -104,14 +104,8 @@ fn pretend_this_is_main() -> Result<(), MyBad> { Err(MyBad { src: Arc::new(src), filename: "bad_file.rs".into(), - snip: SourceSpan { - start: 0.into(), - end: (len - 1).into(), - }, - bad_bit: SourceSpan { - start: 9.into(), - end: 12.into(), - }, + snip: (0, (len - 1)).into(), + bad_bit: (9, 12).into(), }) } ``` diff --git a/src/protocol.rs b/src/protocol.rs index 77747f1..d7ccf44 100644 --- a/src/protocol.rs +++ b/src/protocol.rs @@ -215,6 +215,15 @@ impl SourceSpan { } } +impl From<(ByteOffset, ByteOffset)> for SourceSpan { + fn from((start, end): (ByteOffset, ByteOffset)) -> Self { + Self { + start: start.into(), + end: end.into(), + } + } +} + /** "Raw" type for the byte offset from the beginning of a [Source]. */