cargo-toml-builder 0.3.0

A builder for generating Cargo.toml files
Documentation
  • Coverage
  • 100%
    154 out of 154 items documented68 out of 83 items with examples
  • Size
  • Source code size: 196.09 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 16.16 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 40s Average build duration of successful builds.
  • all releases: 40s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • pwoolcoc

Cargo.toml Builder

Programmatically generate Cargo.toml files

Installation

Add the following to your Cargo.toml file:

[dependencies]
cargo-toml-builder = "0.3"

and the following to your crate root:

extern crate cargo_toml_builder;

Example

extern crate cargo_toml_builder;

use cargo_toml_builder::prelude::*;

let cargo_toml = CargoToml::builder()
                      .name("my-project")
                      .version("1.0.0")
                      .author("Alice Smith <asmith@example.com>")
                      .dependency("env_logger".version("0.5.6"))
                      .feature(Feature::new("nightly").dependency("clippy"))
                      .build()?;

assert_eq!(cargo_toml.to_string(), r#"
[package]
name = "my-project"
version = "1.0.0"
authors = ["Alice Smith <asmith@example.com>"]

[dependencies]
env_logger = "0.5.6"
clippy = {"version" = "*", optional = true}

[features]
nightly = ["clippy"]
"#);