use super::Spans;
use crate::token::{CaptureBuilder, SpanHandle};
use proc_macro::Span;
impl Spans {
#[must_use]
pub const fn empty() -> Self {
Self {
builder: CaptureBuilder::declared(),
}
}
pub(crate) const fn builder(&mut self) -> &mut CaptureBuilder<Span> {
&mut self.builder
}
#[must_use]
pub fn at(&self, handle: SpanHandle) -> Span {
match usize::try_from(handle.index())
.ok()
.and_then(|index| self.builder.positions().get(index).copied())
{
Some(span) => span,
None => Span::call_site(),
}
}
}