Skip to content

Commit

Permalink
refactor!: rename feature for serde (#19)
Browse files Browse the repository at this point in the history
* refactor: rename feature for tests

* chore: add makefile, update readme

* docs: fix readme typo

* ci: update test script format
  • Loading branch information
kade-robertson authored Mar 2, 2023
1 parent 9a99ca6 commit ff12e9f
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-caches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ jobs:
shared-key: 'cache'

- name: Test (to build cache)
run: cargo test --features tests
run: cargo test --all-features
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ jobs:
shared-key: 'cache'

- name: Test
run: cargo test --features tests
run: cargo test --all-features
16 changes: 14 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,19 @@ categories = ["mathematics", "graphics"]
[dependencies]
num-traits = "0.2"
serde = { version = "1.0", features = ["derive"], optional = true }
serde_json = { version = "1.0", optional = true }

[dev-dependencies]
serde_json = "1.0"

[features]
tests = ["dep:serde", "dep:serde_json"]
serde = ["dep:serde"]

[[test]]
name = "integration"
path = "tests/integration.rs"
required-features = ["serde"]

[[bench]]
name = "bench"
path = "benches/bench.rs"
required-features = ["serde"]
7 changes: 7 additions & 0 deletions Makefile.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[tasks.test]
command = "cargo"
args = ["test", "--all-features"]

[tasks.bench]
command = "cargo"
args = ["+nightly", "bench", "--all-features"]
24 changes: 20 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ fn main() {
}
```

## Features

- `serde`, optional, defaults to off. Allows serializing/deserializing points.

## Performance

Measurements taken with an AMD Ryzen 7 5800x, in Pop!\_OS 22.04.
Expand All @@ -47,14 +51,26 @@ Measurements taken with an AMD Ryzen 7 5800x, in Pop!\_OS 22.04.

## Contributing

Running tests:
### Tests

```shell
$ cargo test --all-features
```

or

```shell
$ cargo make test
```

### Benchmarks

```shell
$ cargo test --features tests
$ cargo +nightly bench --all-features
```

Running benchmarks:
or

```shell
$ cargo +nightly bench --features tests
$ cargo make bench
```
5 changes: 2 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#![warn(missing_docs)]
#![warn(rustdoc::missing_doc_code_examples)]
#![doc = include_str!("../README.md")]

pub use traits::ExtendedNumOps;

#[cfg(feature = "tests")]
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};

mod traits;
Expand All @@ -19,7 +18,7 @@ mod traits;
/// let point = Point { x: 1.0, y: 1.0 };
/// ```
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
#[cfg_attr(feature = "tests", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Point<T: ExtendedNumOps> {
/// The x coordinate value.
pub x: T,
Expand Down

0 comments on commit ff12e9f

Please sign in to comment.