zizmor/crates/tree-sitter-iter
William Woodruff 2942f11dc2
Some checks are pending
CodSpeed Benchmarks / Run benchmarks (push) Waiting to run
CI / Lint (push) Waiting to run
CI / Test (push) Waiting to run
CI / Test site build (push) Waiting to run
CI / All tests pass (push) Blocked by required conditions
zizmor wheel builds for PyPI 🐍 / Build Linux wheels (manylinux) (push) Waiting to run
zizmor wheel builds for PyPI 🐍 / Build Linux wheels (musllinux) (push) Waiting to run
zizmor wheel builds for PyPI 🐍 / Build Windows wheels (push) Waiting to run
zizmor wheel builds for PyPI 🐍 / Build macOS wheels (push) Waiting to run
zizmor wheel builds for PyPI 🐍 / Build source distribution (push) Waiting to run
zizmor wheel builds for PyPI 🐍 / Release (push) Blocked by required conditions
Deploy zizmor documentation site 🌐 / Deploy zizmor documentation to GitHub Pages 🌐 (push) Waiting to run
GitHub Actions Security Analysis with zizmor 🌈 / Run zizmor 🌈 (push) Waiting to run
Bump all tree-sitter dependent crates (#1457)
Avoids dep hell.

Signed-off-by: William Woodruff <william@yossarian.net>
2025-12-18 22:36:14 +00:00
..
src feat: track anchors in yamlpath (#1263) 2025-10-19 16:38:33 -04:00
Cargo.toml Bump all tree-sitter dependent crates (#1457) 2025-12-18 22:36:14 +00:00
README.md feat: track anchors in yamlpath (#1263) 2025-10-19 16:38:33 -04:00

tree-sitter-iter

zizmor CI Crates.io docs.rs GitHub Sponsors Discord

A very simple pre-order iterator for tree-sitter CSTs.

This library is part of zizmor.

Usage

Given a tree_sitter::Tree, you can create a TreeIter to iterate over its nodes in pre-order:

use tree_sitter_iter::TreeIter;

let tree: tree_sitter::Tree = parse(); // Your parsing logic here.

for node in TreeIter::new(&tree) {
    println!("Node kind: {}", node.kind());
}

TreeIter implements the standard Iterator trait, meaning that you can use any of the normal iterator combinators. For example, to filter only to nodes of a specific kind:

for node in TreeIter::new(&tree).filter(|n| n.kind() == "call") {
    // Do something with each "call" node.
}

tree-sitter-iter's space and time performance is equivalent to a walk of the tree using the TreeCursor APIs. In other words, it's exactly the same as using a TreeCursor manually, but with a more ergonomic iterator interface.

See the documentation for more details.