3 releases

Uses new Rust 2024

0.0.3 Dec 18, 2025
0.0.2 Oct 19, 2025
0.0.1 Oct 19, 2025

#1273 in Parser implementations

Download history 220/week @ 2025-10-17 248/week @ 2025-10-24 1328/week @ 2025-10-31 297/week @ 2025-11-07 214/week @ 2025-11-14 310/week @ 2025-11-21 304/week @ 2025-11-28 311/week @ 2025-12-05 202/week @ 2025-12-12 296/week @ 2025-12-19 207/week @ 2025-12-26 252/week @ 2026-01-02 332/week @ 2026-01-09

1,134 downloads per month
Used in 6 crates (via yamlpath)

MIT license

7KB
78 lines

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.

Dependencies

~2.7–4MB
~79K SLoC