laarmen / duplicate

Easy code duplicate with substitution for Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

duplicate

Build Status Latest Version Rust Documentation

attribute macro for code duplication with substitution.

This document is meant for contributors to the crate. The documentation is hosted at docs.rs.

Testing

Setup

This crate uses macrotest for testing expansions. Therefore, before running these tests the nightly compiler must be installed together with rustfmt and cargo-expand:

cargo install cargo-expand
rustup toolchain install nightly
rustup component add rustfmt

The tests can then be run normally using cargo test as seen below.

Tests are divided into the following groups:

  • no_features: Tests the minimal API of the crate with no features enabled.
cargo test --no-default-features -- --skip default_features::
  • default_features: Test that the correct features are enabled by default. This is to ensure a change doesn't change which features are on by default. However, this does not test the features themselves.
cargo test default_features::
  • features: Tests any combination of features. After --features add a comma separated list of features to test:
cargo test --features module_disambiguation,pretty_errors -- --skip default_features::
  • documentation: Tests code in the documentation. Even though some of the other test groups might test some of the documentaion code, they are not guaranteed to run all tests. E.g. the test of the cargo readme file (cargo-readme.md are only run when this command is used.
cargo test --doc --all-features

Formatting

We use rustfmt to manage the formatting of this crate's code. To have cargo format the code for you, you must have the nightly compiler installed (but not necessarily the default) and then run the command:

cargo +nightly fmt

Travis-CI will check the formatting and fail if it isn't formatted correctly.

Release Deployment

Deployment of new versions of this crate is managed by Travis-CI using git tags. To trigger a new release, simply push a tag to the repository containing only the version number:

git tag 1.0.0
git push --tags

We do not use the Cargo.toml to manage the versioning of this crate. The version given in it should not be changed! It must remain as 0.0.0 so Travis-CI can correctly change it for every release.

Travis will also reset the change log as part of the release, so do not change the ## [Unreleased] line nor add an entry for new releases yourself.

Travis will also add the new release's changes to cargo-readme.md under the Changelog section. So do not touch that either.

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

Easy code duplicate with substitution for Rust

License:Apache License 2.0


Languages

Language:Rust 100.0%