Skip to content

Commit

Permalink
Rollback macros feature flag due to dependency resolution issues (#643)
Browse files Browse the repository at this point in the history
  • Loading branch information
paupino committed Feb 1, 2024
1 parent 999bb02 commit 179039a
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .buildnumber
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
1
34
1
2
7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ name = "rust_decimal"
readme = "./README.md"
repository = "https://github.com/paupino/rust-decimal"
rust-version = "1.60"
version = "1.34.1"
version = "1.34.2"

[package.metadata.docs.rs]
all-features = true
Expand All @@ -32,7 +32,7 @@ proptest = { default-features = false, optional = true, features = ["std"], vers
rand = { default-features = false, optional = true, version = "0.8" }
rkyv = { default-features = false, features = ["size_32", "std"], optional = true, version = "0.7.42" }
rocket = { default-features = false, optional = true, version = "0.5.0-rc.3" }
rust_decimal_macros = { default-features = false, optional = true, version = "1.34" } # This needs to a published version
#rust_decimal_macros = { default-features = false, optional = true, version = "1.34" } # This needs to a published version
serde = { default-features = false, optional = true, version = "1.0" }
serde_json = { default-features = false, optional = true, version = "1.0" }
tokio-postgres = { default-features = false, optional = true, version = "0.7" }
Expand All @@ -52,7 +52,8 @@ version-sync = { default-features = false, features = ["html_root_url_updated",

[features]
default = ["serde", "std"]
macros = ["dep:rust_decimal_macros"]
# Removed in 1.34.2 due to an issue during version resolution
#macros = ["dep:rust_decimal_macros"]

borsh = ["dep:borsh", "std"]
c-repr = [] # Force Decimal to be repr(C)
Expand Down
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,26 @@ The binary representation consists of a 96 bit integer number, a scaling factor
$ cargo add rust_decimal
```

If you would like to use the optimized macro for convenient creation of decimals you can add `rust_decimal` with the `macros` feature flag:
In addition, if you would like to use the optimized macro for convenient creation of decimals:

```sh
$ cargo add rust_decimal --features macros
$ cargo add rust_decimal_macros
```

Alternatively, you can edit your `Cargo.toml` directly and run `cargo update`:

```toml
[dependencies]
rust_decimal = { version = "1.34", features = ["macros"] }
rust_decimal = "1.34"
rust_decimal_macros = "1.34"
```

## Usage

Decimal numbers can be created in a few distinct ways. The easiest and most efficient method of creating a Decimal is to use the procedural macro that can be enabled using the `macros` feature:

```rust
// The macros feature exposes a `dec` macro which will parse the input into a raw decimal number at compile time.
// It is also exposed when using `rust_decimal::prelude::*`. That said, you can also import the
// `rust_decimal_macros` crate and use the macro directly from there.
// Import the `rust_decimal_macros` crate and use the macro directly from there.
use rust_decimal_macros::dec;

let number = dec!(-1.23) + dec!(3.45);
Expand Down
3 changes: 2 additions & 1 deletion examples/serde-json-scenarios/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ publish = false
[workspace]

[dependencies]
rust_decimal = { path = "../..", features = ["macros", "serde-with-arbitrary-precision"] }
rust_decimal = { path = "../..", features = ["serde-with-arbitrary-precision"] }
rust_decimal_macros = { path = "../../macros" }
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0", features = ["arbitrary_precision"]}
1 change: 1 addition & 0 deletions examples/serde-json-scenarios/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use rust_decimal::prelude::*;
use rust_decimal_macros::dec;

type ExampleResult = Result<(), Box<dyn std::error::Error>>;

Expand Down
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ pub use error::Error;
#[cfg(feature = "maths")]
pub use maths::MathematicalOps;

#[cfg(feature = "macros")]
pub use rust_decimal_macros::dec;
// #[cfg(feature = "macros")]
// pub use rust_decimal_macros::dec;

/// A convenience module appropriate for glob imports (`use rust_decimal::prelude::*;`).
pub mod prelude {
Expand All @@ -68,8 +68,8 @@ pub mod prelude {
pub use crate::{Decimal, RoundingStrategy};
pub use core::str::FromStr;
pub use num_traits::{FromPrimitive, One, Signed, ToPrimitive, Zero};
#[cfg(feature = "macros")]
pub use rust_decimal_macros::dec;
// #[cfg(feature = "macros")]
// pub use rust_decimal_macros::dec;
}

#[cfg(all(feature = "diesel1", not(feature = "diesel2")))]
Expand Down

0 comments on commit 179039a

Please sign in to comment.