diff options
Diffstat (limited to 'src/syntax/source.rs')
| -rw-r--r-- | src/syntax/source.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/syntax/source.rs b/src/syntax/source.rs index 052e841a..53cc6de9 100644 --- a/src/syntax/source.rs +++ b/src/syntax/source.rs @@ -152,18 +152,18 @@ impl Source { /// Find the node with the given span. /// - /// Panics if the span does not point into this source file. - pub fn find(&self, span: Span) -> LinkedNode<'_> { - LinkedNode::new(&self.root) - .find(span) - .expect("span does not point into this source file") + /// Returns `None` if the span does not point into this source file. + pub fn find(&self, span: Span) -> Option<LinkedNode<'_>> { + LinkedNode::new(&self.root).find(span) } /// Map a span that points into this source file to a byte range. /// /// Panics if the span does not point into this source file. pub fn range(&self, span: Span) -> Range<usize> { - self.find(span).range() + self.find(span) + .expect("span does not point into this source file") + .range() } /// Return the index of the UTF-16 code unit at the byte index. |
