crate-metadata

Crates.iocrate-metadata
lib.rscrate-metadata
version0.1.1
sourcesrc
created_at2022-10-05 12:13:11.682426
updated_at2023-04-22 18:35:41.381938
descriptionUtility functions to get current crate metadata.
homepagehttps://github.com/boozook/crate-metadata
repositoryhttps://github.com/boozook/crate-metadata.git
max_upload_size
id680481
size10,561
Alexander Koz. (boozook)

documentation

https://docs.rs/crate-metadata

README

Cargo Crate Metadata

For usage from build-script.

Utility functions that returns current crate metadata as result of call cargo metadata.

Example

Cargo.toml:

# ...

[package.metadata]
foo = "bar"

# ...

build.rs

extern crate serde;
extern crate serde_json;
extern crate crate_metadata;

use serde::Deserialize;


fn main() {
	let metadata = crate_metadata::crate_metadata::<MyMeta>().unwrap();
	assert_eq!("bar", &metadata.packages.first().unwrap().metadata.unwrap().foo);
}


#[derive(Deserialize, Debug)]
struct MyMeta {
	pub foo: String,
}
Commit count: 6

cargo fmt