pub trait Spanned {
// Required method
fn span(&self, ctx: &Context) -> Span;
// Provided methods
fn file<'ctx>(&self, ctx: &'ctx Context) -> File<'ctx> { ... }
fn start(&self, ctx: &Context) -> usize { ... }
fn end(&self, ctx: &Context) -> usize { ... }
fn is_empty(&self, ctx: &Context) -> bool { ... }
fn len(&self, ctx: &Context) -> usize { ... }
fn text<'ctx>(&self, ctx: &'ctx Context) -> &'ctx str { ... }
fn comments<'ctx>(&self, ctx: &'ctx Context) -> Comments<'ctx> { ... }
}
Expand description
A syntax element which contains a span.
You should implement this type for any type which naturally has a single span that describes it.
Required Methods§
Provided Methods§
sourcefn file<'ctx>(&self, ctx: &'ctx Context) -> File<'ctx>
fn file<'ctx>(&self, ctx: &'ctx Context) -> File<'ctx>
Forwards to SpanId::file()
.
sourcefn start(&self, ctx: &Context) -> usize
fn start(&self, ctx: &Context) -> usize
Forwards to Span::start()
.
sourcefn end(&self, ctx: &Context) -> usize
fn end(&self, ctx: &Context) -> usize
Forwards to Span::end()
.
sourcefn is_empty(&self, ctx: &Context) -> bool
fn is_empty(&self, ctx: &Context) -> bool
Forwards to Span::is_empty()
.
sourcefn len(&self, ctx: &Context) -> usize
fn len(&self, ctx: &Context) -> usize
Forwards to Span::len()
.
sourcefn text<'ctx>(&self, ctx: &'ctx Context) -> &'ctx str
fn text<'ctx>(&self, ctx: &'ctx Context) -> &'ctx str
Forwards to SpanId::text()
.
sourcefn comments<'ctx>(&self, ctx: &'ctx Context) -> Comments<'ctx>
fn comments<'ctx>(&self, ctx: &'ctx Context) -> Comments<'ctx>
Forwards to SpanId::comments()
.