luaur_ast/records/location.rs
1//! Faithful port of Luau `Location` (`Ast/include/Luau/Location.h`).
2//!
3//! A half-open source span `begin..end`. C++ defines `operator==`/`!=` (collapse
4//! into the derived `PartialEq`/`Eq`) but no ordering. `Default` is the
5//! all-zero span, matching the C++ `Location()` default constructor. The four
6//! `Location(...)` constructors and the `encloses`/`overlaps`/`contains`/
7//! `extend`/`shift` methods are separate items.
8
9use crate::records::position::Position;
10
11#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
12pub struct Location {
13 pub begin: Position,
14 pub end: Position,
15}
16
17// Usable as a `DenseHashMap` value (e.g. `Parser::declared_export_bindings`); the
18// empty slot is the all-zero span, matching C++ value-initialization.
19impl luaur_common::records::dense_hash_table::DenseDefault for Location {
20 fn dense_default() -> Self {
21 Location::default()
22 }
23}