pub struct Span {
pub start: SpanValue,
pub end: SpanValue,
}Expand description
The Span type represents an area of a file.
Fields§
§start: SpanValueThe start of the Span.
end: SpanValueThe end of the Span.
Implementations§
Source§impl Span
impl Span
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new Span. This span will start and end at the 0th character, making it have a length of zero.
Sourcepub fn new_from(start: SpanValue, end: SpanValue) -> Self
pub fn new_from(start: SpanValue, end: SpanValue) -> Self
Creates a new Span from a pair of start and end indexes. These indexes are indexes into a string by chars.
Sourcepub fn grow_front(&mut self, amount: SpanValue)
pub fn grow_front(&mut self, amount: SpanValue)
Grows the span from the front. This moves the end value up by amount.
Sourcepub fn grow_back(&mut self, amount: SpanValue)
pub fn grow_back(&mut self, amount: SpanValue)
Grows the span from the back. This moves the start value back by amount.
§Panics
Panics if the start of the span is less than amount, since spans can’t have a negative start value,
Sourcepub fn shrink_back(&mut self, amount: SpanValue)
pub fn shrink_back(&mut self, amount: SpanValue)
Shrinks the span from the back. This moves the start value up by amount.
§Panics
Panics if the size of the Span is less than amount, since a Span’s size can’t be negative.
Sourcepub fn shrink_front(&mut self, amount: SpanValue)
pub fn shrink_front(&mut self, amount: SpanValue)
Shrinks the span from the front. This moves the end value back by amount.
§Panics
This method will panic if the size of the Span is less than amount, since a Span’s size can’t be negative.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Checks if a Span’s size is 0. Returns true if 0, and false if anything else.