pub struct Index {
pub target: Box<Expr>,
pub index: Box<Expr>,
pub span: Range<usize>,
pub bracket_span: Range<usize>,
}Expand description
List indexing, such as list[0].
Fields§
§target: Box<Expr>The expression being indexed.
index: Box<Expr>The amount to index by.
span: Range<usize>The region of the source code that this function call was parsed from.
bracket_span: Range<usize>The span of the brackets that surround the index expression.
Implementations§
Source§impl Index
impl Index
Sourcepub fn outer_span(&self) -> [Range<usize>; 2]
pub fn outer_span(&self) -> [Range<usize>; 2]
Returns a set of two spans, where the first is the span of the expression being indexed (with the opening bracket) and the second is the span of the closing bracket.
Sourcepub fn parse_or_lower(
input: &mut Parser<'_>,
recoverable_errors: &mut Vec<Error>,
target: Primary,
) -> (Primary, bool)
pub fn parse_or_lower( input: &mut Parser<'_>, recoverable_errors: &mut Vec<Error>, target: Primary, ) -> (Primary, bool)
Attempts to parse an Index, where the initial target has already been parsed.
Besides the returned Primary, the return value also includes a boolean that indicates
if the expression was changed due to successfully parsing a Index. This function can
return even if no Index, which occurs when we determine that we shouldn’t have taken the
Index path. The boolean is used to let the caller know that this is was the case.
This is similar to what we had to do with Binary.
Trait Implementations§
Source§impl From<Index> for AssignTarget
impl From<Index> for AssignTarget
Source§impl Latex for Index
impl Latex for Index
Source§fn as_display(&self) -> LatexFormatter<'_, Self>
fn as_display(&self) -> LatexFormatter<'_, Self>
LatexFormatter, which implements Display.