pub struct Span {
pub start: Location,
pub end: Location,
}
Expand description
Represents an interval of characters in the original SQL query.
Fields§
§start: Location
§end: Location
Implementations§
Source§impl Span
impl Span
Sourcepub fn try_from_sqlparser_span(span: Span) -> Option<Span>
pub fn try_from_sqlparser_span(span: Span) -> Option<Span>
Sourcepub fn union(&self, other: &Span) -> Span
pub fn union(&self, other: &Span) -> Span
Returns the smallest Span that contains both self
and other
§Examples
// line 1, column1 -> line 2, column 5
let span1 = Span::new(Location::new(1, 1), Location::new(2, 5));
// line 2, column 3 -> line 3, column 7
let span2 = Span::new(Location::new(2, 3), Location::new(3, 7));
// Union of the two is the min/max of the two spans
// line 1, column 1 -> line 3, column 7
let union = span1.union(&span2);
assert_eq!(union, Span::new(Location::new(1, 1), Location::new(3, 7)));
Sourcepub fn union_opt(&self, other: &Option<Span>) -> Span
pub fn union_opt(&self, other: &Option<Span>) -> Span
Same as Span::union for Option<Span>
.
If other
is None
, self
is returned.
Sourcepub fn union_iter<I: IntoIterator<Item = Span>>(iter: I) -> Option<Span>
pub fn union_iter<I: IntoIterator<Item = Span>>(iter: I) -> Option<Span>
Return the Span::union of all spans in the iterator.
If the iterator is empty, None
is returned.
§Example
let spans = vec![
Span::new(Location::new(1, 1), Location::new(2, 5)),
Span::new(Location::new(2, 3), Location::new(3, 7)),
Span::new(Location::new(3, 1), Location::new(4, 2)),
];
// line 1, column 1 -> line 4, column 2
assert_eq!(
Span::union_iter(spans),
Span::new(Location::new(1, 1), Location::new(4, 2))
);
Trait Implementations§
Source§impl Ord for Span
impl Ord for Span
Source§impl PartialOrd for Span
impl PartialOrd for Span
impl Copy for Span
impl Eq for Span
impl StructuralPartialEq for Span
Auto Trait Implementations§
impl Freeze for Span
impl RefUnwindSafe for Span
impl Send for Span
impl Sync for Span
impl Unpin for Span
impl UnwindSafe for Span
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more