mirror of https://github.com/zkat/miette.git
feat(protocol): implement From<(usize, usize)> for SourceSpan
This commit is contained in:
parent
f704d6a9ae
commit
36b86df9f5
10
README.md
10
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(),
|
||||
})
|
||||
}
|
||||
```
|
||||
|
|
|
|||
|
|
@ -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].
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue