I ran into the following problem today. I have a Cargo.toml file, linking to docs.rs as a documentation link. It looks like this:
[package]
name = "my_lib"
version = "1.0.1"
documentation = "https://docs.rs/my_lib/1.0.1/"
The problem is that - on any update - I have to keep those two version strings in sync.
Would it make sense to allow interpolation in strings in Cargo.toml? As an example
[package]
name = "my_lib"
version = "1.0.1"
documentation = "https://docs.rs/my_lib/{$package.version}/"
Iām aware that this leads down the road of Maven, but I think it is a reasonable motivating example. On the other hand, Iām not sure how pervasive that problem is otherwise.
Another option would be to hand off such a task to tools like cargo-edit, but that would lead down the road of having an ever-expanding, de facto necessary toolchain, just to keep the core of the language.
IMO this seems like an issue for toml, not cargo. Adding this to cargo post-toml parsing would be a significant divergence from the standard, and having a specified standard was the reason we adopted toml.
Hand off the substitution task? Or just the redundant version bumps? I think the latter is totally reasonable, to have a tool that knows how to bump both a version and docs.rs in tandem, and it's not "de facto necessary" if it's just doing something you can still do manually.
One data point: in our project (Fuchsia) weāre struggling with how to point to generated IDL binding crates (the directory where the generated code goes is variable), and interpolation has come up as one possible solution. Iām not saying itās the best solution, but if this were to be adopted, we would find it useful.
I don't see how that would go against the TOML format. The spec itself includes strings as examples which are later subject to substitution. (not through values from the same file, I give you that). I still do not see how TOML would prohibit further interpretations of the values given in the file.
It doesnāt violate the spec, but it does diverge from it. Substitutions ought happen during the parsing layer, not during the layer at which cargo operates. We are applying additional layers of syntactic significance to strings that donāt exist in the TOML format. Suppose toml does add substitutions like this, but using a different syntax. Now we have to support two redundant string interpolation formats.
Well, thatās the danger of using a format marked as version 0.4.0 as the first big user.
In that case, such a feature should be discussed with the relevant team before, but that shouldnāt factor into the discussion whether thatās a desired feature or not for Cargo.