#scan #enums #traits #struct #workspace #file #type


simple crate -- lets us scan crate(s) for locally defined structs, enums, types, fns, and traits

7 releases (breaking)

0.8.0 Sep 20, 2023
0.7.0 Sep 20, 2023
0.6.0 Sep 15, 2023
0.5.0 Sep 14, 2023
0.1.0 Sep 14, 2023

#121 in #scan

Download history 3/week @ 2024-02-24 12/week @ 2024-03-02 135/week @ 2024-03-09 1/week @ 2024-03-16

151 downloads per month

MIT license

566 lines


This is a simple crate that lets us scan one or all crates in the current workspace.

We can also use it to scan a vendored crate.

This helps us search a crate directly for trait, fn, struct, enum, type names, and macro defs.

This crate uses the rust-analyzer API to perform the heavy lifting.


I typically use it like this:

scan-crate-for-typedefs = "0.6.0"
//this is the `build.rs` file for one of the most
// stable crates in the workspace:

use scan_crate_for_typedefs::*;

fn main() -> std::io::Result<()> {

    let typemap = PersistentWorkspaceTypeMap::new_with_path("..")?;


Then, all we have to do is build the project and we get a rust-workspace-typemap.json at the top-level

I typically parse the output of cargo build to find types which cannot be found.

Next, I scan the index contained within file to figure out which crate they belong to.


~359K SLoC