Trait python_ast::ast::node::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<S1: Into<String>, S2: Into<String>>(
        &self,
        mod_name: S1,
        message: S2
    ) -> 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<S1: Into<String>, S2: Into<String>>( &self, mod_name: S1, message: S2 ) -> String

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

Object Safety§

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§