implement Spanned for {Span, BytePos}

This commit is contained in:
강동윤 2018-03-04 14:41:59 +09:00
parent d5ef2be32a
commit 3321ca590d

View File

@ -11,6 +11,21 @@ pub trait Spanned {
fn span(&self) -> Span;
}
impl Spanned for Span {
#[inline(always)]
fn span(&self) -> Span {
*self
}
}
impl Spanned for BytePos {
/// Creates a new single-byte span.
#[inline(always)]
fn span(&self) -> Span {
Span::new(*self, *self, Default::default())
}
}
impl<S> Spanned for Box<S>
where
S: ?Sized + Spanned,