cargo-toml-builder

Crates.iocargo-toml-builder
lib.rscargo-toml-builder
version0.3.0
sourcesrc
created_at2018-04-02 20:19:30.022457
updated_at2019-05-02 16:05:53.73888
descriptionA builder for generating Cargo.toml files
homepage
repositoryhttps://gitlab.com/pwoolcoc/cargo-toml-builder
max_upload_size
id58697
size187,266
Paul Woolcock (pwoolcoc)

documentation

https://docs.rs/cargo-toml-builder

README

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"]
"#);
Commit count: 0

cargo fmt