#scan #workspace #syntax #crates #typedefs

build scan-crate-for-typedefs

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

8 releases (breaking)

0.8.1 Oct 6, 2024
0.8.0 Sep 20, 2023
0.7.0 Sep 20, 2023
0.6.0 Sep 15, 2023
0.1.0 Sep 14, 2023

#41 in #crate

Download history 609/week @ 2025-10-27 746/week @ 2025-11-03 669/week @ 2025-11-10 842/week @ 2025-11-17 705/week @ 2025-11-24 813/week @ 2025-12-01 547/week @ 2025-12-08 709/week @ 2025-12-15 863/week @ 2025-12-22 681/week @ 2025-12-29 556/week @ 2026-01-05 338/week @ 2026-01-12 944/week @ 2026-01-19 853/week @ 2026-01-26 825/week @ 2026-02-02 602/week @ 2026-02-09

3,276 downloads per month
Used in 478 crates (7 directly)

MIT license

36KB
563 lines

Overview

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.

Usage

I typically use it like this:

[build-dependencies]
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("..")?;

    Ok(())
}

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.

Dependencies

~15–33MB
~421K SLoC