Struct syntax::ast_map::Map [−] [src]

pub struct Map<'ast> {
    // some fields omitted
}
Unstable

Represents a mapping from Node IDs to AST elements and their parent Node IDs

Methods

impl<'ast> Map<'ast>

fn krate(&self) -> &'ast Crate

Unstable

fn get(&self, id: NodeId) -> Node<'ast>

Unstable

Retrieve the Node corresponding to id, panicking if it cannot be found.

fn find(&self, id: NodeId) -> Option<Node<'ast>>

Unstable

Retrieve the Node corresponding to id, returning None if cannot be found.

fn get_parent(&self, id: NodeId) -> NodeId

Unstable

Retrieve the parent NodeId for id, or id itself if no parent is registered in this map.

fn get_parent_did(&self, id: NodeId) -> DefId

Unstable

fn get_foreign_abi(&self, id: NodeId) -> Abi

Unstable

fn get_foreign_vis(&self, id: NodeId) -> Visibility

Unstable

fn expect_item(&self, id: NodeId) -> &'ast Item

Unstable

fn expect_struct(&self, id: NodeId) -> &'ast StructDef

Unstable

fn expect_variant(&self, id: NodeId) -> &'ast Variant

Unstable

fn expect_foreign_item(&self, id: NodeId) -> &'ast ForeignItem

Unstable

fn expect_expr(&self, id: NodeId) -> &'ast Expr

Unstable

fn get_path_elem(&self, id: NodeId) -> PathElem

Unstable

returns the name associated with the given NodeId's AST

fn with_path<T, F>(&self, id: NodeId, f: F) -> T where F: FnOnce(PathElems) -> T

Unstable

fn path_to_string(&self, id: NodeId) -> String

Unstable

fn attrs(&self, id: NodeId) -> &'ast [Attribute]

Unstable

Given a node ID, get a list of of attributes associated with the AST corresponding to the Node ID

fn nodes_matching_suffix<'a>(&'a self, parts: &'a [String]) -> NodesMatchingSuffix<'a, 'ast>

Unstable

Returns an iterator that yields the node id's with paths that match parts. (Requires parts is non-empty.)

For example, if given parts equal to ["bar", "quux"], then the iterator will produce node id's for items with paths such as foo::bar::quux, bar::quux, other::bar::quux, and any other such items it can find in the map.

fn opt_span(&self, id: NodeId) -> Option<Span>

Unstable

fn span(&self, id: NodeId) -> Span

Unstable

fn def_id_span(&self, def_id: DefId, fallback: Span) -> Span

Unstable

fn node_to_string(&self, id: NodeId) -> String

Unstable

fn node_to_user_string(&self, id: NodeId) -> String

Unstable