Adding a custom value into a Cargo.toml file

Viewed 525

Background

I'm currently in the process of writing a crate that's bindings for a C library and I need the user to specify where the built library is. Previously, I've seen this handles by the llvm-sys crate using environment variables. However, having used this a lot it can become quite cumbersome to have to write this every time I want to run a project.

similar questions

I found this post that asked a similar thing, but seemed to only be able to use specified tags, so not able to specify a path.

What I want to do

I would like to know if there's any way I can have a specific custom value in the Cargo.toml file. The idea being the crate I'm writing would require a specific value (I'll call it example here) that can take any string value. so when this crate were to be used in another project, that projects Cargo.toml file would be similar to this::

[package]
name = "some-other-project"
version = "0.1.0"
edition = "2021"

[dependencies.my_crate]
version = "0.1.0"
example = "something goes here"

This value would then be accessible by the crate I'm writing (the dependency in regards to the above manifest file) and usable in some way.

1 Answers
Related