Trait python_ast::codegen::Node

source ·
pub trait Node<'a> {
    // 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: &'a str, message: &'a 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: &'a str, message: &'a str) -> String

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

Implementations on Foreign Types§

source§

impl<'a> Node<'a> 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§

source§

impl<'a> Node<'a> for Statement