Trait Node

Source
pub trait Node {
    // Provided methods
    fn lineno(&self) -> Option<usize> { ... }
    fn col_offset(&self) -> Option<usize> { ... }
    fn end_lineno(&self) -> Option<usize> { ... }
    fn end_col_offset(&self) -> Option<usize> { ... }
    fn error_message(
        &self,
        mod_name: impl AsRef<str>,
        message: impl AsRef<str>,
    ) -> String { ... }
}
Expand description

A trait for AST elements that represent a position in a source file. Implementing this trait allows an ergonomic means of extracting line and column information from an item.

Provided Methods§

Source

fn lineno(&self) -> Option<usize>

A method for getting the starting line number of the node. This may not exist for all node types.

Source

fn col_offset(&self) -> Option<usize>

A method for getting the starting column of the node. This may not exist for all node types.

Source

fn end_lineno(&self) -> Option<usize>

A method for getting the ending line number of the node. This may not exist for all node types.

Source

fn end_col_offset(&self) -> Option<usize>

A method for getting the ending column of the node. This may not exist for all node types.

Source

fn error_message( &self, mod_name: impl AsRef<str>, message: impl AsRef<str>, ) -> String

Generate an error message for the current code, adding line and column number.

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.

Implementations on Foreign Types§

Source§

impl Node for PyAny

Source§

fn lineno(&self) -> Option<usize>

A method for getting the starting line number of the node. This may not exist for all node types.

Source§

fn col_offset(&self) -> Option<usize>

A method for getting the starting column of the node. This may not exist for all node types.

Source§

fn end_lineno(&self) -> Option<usize>

A method for getting the ending line number of the node. This may not exist for all node types.

Source§

fn end_col_offset(&self) -> Option<usize>

A method for getting the ending column of the node. This may not exist for all node types.

Implementors§