Skip to content

Commit

Permalink
Merge #21
Browse files Browse the repository at this point in the history
21: Release 0.4.0 r=taiki-e a=taiki-e

Changes:

* [Add support for version-based code generation.](#17) The following conditions are available:

  ```rust
  use const_fn::const_fn;

  // function is `const` on specified version and later compiler (including beta and nightly)
  #[const_fn("1.36")]
  pub const fn version() {
      /* ... */
  }

  // function is `const` on nightly compiler (including dev build)
  #[const_fn(nightly)]
  pub const fn nightly() {
      /* ... */
  }

  // function is `const` if `cfg(...)` is true
  #[const_fn(cfg(...))]
  pub const fn cfg() {
      /* ... */
  }

  // function is `const` if `cfg(feature = "...")` is true
  #[const_fn(feature = "...")]
  pub const fn feature() {
      /* ... */
  }
  ```

* Improve compile time by removing proc-macro related dependencies ([#18](#18), [#20](#20)).

Co-authored-by: Taiki Endo <[email protected]>
  • Loading branch information
bors[bot] and taiki-e authored Aug 25, 2020
2 parents 12672ab + 708a50d commit 9383c4a
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 14 deletions.
37 changes: 36 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,40 @@ This project adheres to [Semantic Versioning](https://semver.org).

## [Unreleased]

## [0.4.0] - 2020-08-25

* [Add support for version-based code generation.](https://github.com/taiki-e/const_fn/pull/17) The following conditions are available:

```rust
use const_fn::const_fn;

// function is `const` on specified version and later compiler (including beta and nightly)
#[const_fn("1.36")]
pub const fn version() {
/* ... */
}

// function is `const` on nightly compiler (including dev build)
#[const_fn(nightly)]
pub const fn nightly() {
/* ... */
}

// function is `const` if `cfg(...)` is true
#[const_fn(cfg(...))]
pub const fn cfg() {
/* ... */
}

// function is `const` if `cfg(feature = "...")` is true
#[const_fn(feature = "...")]
pub const fn feature() {
/* ... */
}
```

* Improve compile time by removing proc-macro related dependencies ([#18](https://github.com/taiki-e/const_fn/pull/18), [#20](https://github.com/taiki-e/const_fn/pull/20)).

## [0.3.1] - 2019-12-09

* Updated `syn-mid` to 0.5.
Expand Down Expand Up @@ -56,7 +90,8 @@ This project adheres to [Semantic Versioning](https://semver.org).

Initial release

[Unreleased]: https://github.com/taiki-e/const_fn/compare/v0.3.1...HEAD
[Unreleased]: https://github.com/taiki-e/const_fn/compare/v0.4.0...HEAD
[0.4.0]: https://github.com/taiki-e/const_fn/compare/v0.3.1...v0.4.0
[0.3.1]: https://github.com/taiki-e/const_fn/compare/v0.3.0...v0.3.1
[0.3.0]: https://github.com/taiki-e/const_fn/compare/v0.2.1...v0.3.0
[0.2.1]: https://github.com/taiki-e/const_fn/compare/v0.2.0...v0.2.1
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "const_fn"
version = "0.3.1"
version = "0.4.0"
authors = ["Taiki Endo <[email protected]>"]
edition = "2018"
license = "Apache-2.0 OR MIT"
Expand All @@ -11,7 +11,7 @@ keywords = ["macros", "attribute", "const", "static"]
categories = ["rust-patterns"]
readme = "README.md"
description = """
An attribute for easy generation of a const function with conditional compilations.
An attribute for easy generation of const functions with conditional compilations.
"""

[package.metadata.docs.rs]
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
[rustc-badge]: https://img.shields.io/badge/rustc-1.31+-lightgray.svg
[rustc-url]: https://blog.rust-lang.org/2018/12/06/Rust-1.31-and-rust-2018.html

An attribute for easy generation of a const function with conditional compilations.
An attribute for easy generation of const functions with conditional compilations.

## Usage

Add this to your `Cargo.toml`:

```toml
[dependencies]
const_fn = "0.3"
const_fn = "0.4"
```

The current const_fn requires Rust 1.31 or later.
Expand All @@ -32,25 +32,25 @@ The current const_fn requires Rust 1.31 or later.
```rust
use const_fn::const_fn;

// 1.36 and later compiler (including beta and nightly)
// function is `const` on specified version and later compiler (including beta and nightly)
#[const_fn("1.36")]
pub const fn version() {
/* ... */
}

// nightly compiler (including dev build)
// function is `const` on nightly compiler (including dev build)
#[const_fn(nightly)]
pub const fn nightly() {
/* ... */
}

// `cfg(...)`
// function is `const` if `cfg(...)` is true
#[const_fn(cfg(...))]
pub const fn cfg() {
/* ... */
}

// `cfg(feature = "...")`
// function is `const` if `cfg(feature = "...")` is true
#[const_fn(feature = "...")]
pub const fn feature() {
/* ... */
Expand Down
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,34 @@
//! ```rust
//! use const_fn::const_fn;
//!
//! // 1.36 and later compiler (including beta and nightly)
//! // function is `const` on specified version and later compiler (including beta and nightly)
//! #[const_fn("1.36")]
//! pub const fn version() {
//! /* ... */
//! }
//!
//! // nightly compiler (including dev build)
//! // function is `const` on nightly compiler (including dev build)
//! #[const_fn(nightly)]
//! pub const fn nightly() {
//! /* ... */
//! }
//!
//! // `cfg(...)`
//! // function is `const` if `cfg(...)` is true
//! # #[cfg(any())]
//! #[const_fn(cfg(...))]
//! # pub fn _cfg() { unimplemented!() }
//! pub const fn cfg() {
//! /* ... */
//! }
//!
//! // `cfg(feature = "...")`
//! // function is `const` if `cfg(feature = "...")` is true
//! #[const_fn(feature = "...")]
//! pub const fn feature() {
//! /* ... */
//! }
//! ```
#![doc(html_root_url = "https://docs.rs/const_fn/0.3.1")]
#![doc(html_root_url = "https://docs.rs/const_fn/0.4.0")]
#![doc(test(
no_crate_inject,
attr(deny(warnings, rust_2018_idioms, single_use_lifetimes), allow(dead_code))
Expand Down

0 comments on commit 9383c4a

Please sign in to comment.