scan-crate-for-typedefs

Crates.ioscan-crate-for-typedefs
lib.rsscan-crate-for-typedefs
version0.8.1
sourcesrc
created_at2023-09-14 20:24:21.18309
updated_at2024-10-06 14:27:57.171608
descriptionsimple crate -- lets us scan crate(s) for locally defined structs, enums, types, fns, and traits
homepagehttps://github.com/klebs6/klebs-general
repositoryhttps://github.com/klebs6/klebs-general
max_upload_size
id973063
size49,276
(klebs6)

documentation

https://docs.rs/scan-crate-for-typedefs

README

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.

Commit count: 248

cargo fmt