pub trait SpanExt {
    // Required methods
    fn subtract(&self, child_spans: Vec<Span>) -> Vec<Span>;
    fn as_local(&self, outer_span: Span) -> Option<Span>;
    fn overlaps_inclusive(&self, other: Span) -> bool;
    fn trim_end(&self, other: Span) -> Option<Span>;
    fn merge_overlaps(spans: Vec<Span>) -> Vec<Span>;
    fn trim_leading_whitespace(
        &self,
        source_map: &SourceMap,
    ) -> Option<Vec<Span>>;
    fn to_string(&self, tcx: TyCtxt<'_>) -> String;
    fn size(&self) -> u32;
}Expand description
Extension trait for Span.
Required Methods§
Sourcefn subtract(&self, child_spans: Vec<Span>) -> Vec<Span>
 
fn subtract(&self, child_spans: Vec<Span>) -> Vec<Span>
Returns spans for regions in self not in child_spans.
For example:
self:          ---------------
child_spans:    ---      --  ---
output:        -   ------  --Sourcefn as_local(&self, outer_span: Span) -> Option<Span>
 
fn as_local(&self, outer_span: Span) -> Option<Span>
Returns the version of this span that is local to the current
crate, and must be contained in outer_span.
Sourcefn overlaps_inclusive(&self, other: Span) -> bool
 
fn overlaps_inclusive(&self, other: Span) -> bool
Returns true if self overlaps with other including boundaries.
Sourcefn trim_end(&self, other: Span) -> Option<Span>
 
fn trim_end(&self, other: Span) -> Option<Span>
Returns a new span whose end is no later than the start of other,
returning None if this would return an empty span.
Sourcefn merge_overlaps(spans: Vec<Span>) -> Vec<Span>
 
fn merge_overlaps(spans: Vec<Span>) -> Vec<Span>
Merges all overlapping spans in the input vector into single spans.
Sourcefn trim_leading_whitespace(&self, source_map: &SourceMap) -> Option<Vec<Span>>
 
fn trim_leading_whitespace(&self, source_map: &SourceMap) -> Option<Vec<Span>>
Returns a collection of spans inside self that have leading whitespace removed.
Returns None if SourceMap::span_to_snippet fails.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.