Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Talk about tests and benchmarks
Browse files Browse the repository at this point in the history
Philippe-Cholet committed Feb 7, 2024
1 parent 1075507 commit d8c785f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -10,6 +10,9 @@ then **please first file an issue** describing your proposal._
To pass CI tests successfully, your code must be free of "compiler warnings" and "clippy warnings" and be "rustfmt" formatted.

## Write a new method/adaptor for `Itertools` trait
In general, the code logic should be tested with [quickcheck](https://crates.io/crates/quickcheck) tests in `tests/quick.rs`
which allow us to test properties about the code with randomly generated inputs.

### Behind `use_std`/`use_alloc` feature?
If it needs the "std" (such as using hashes) then it should be behind the `use_std` feature,
or if it requires heap allocation (such as using vectors) then it should be behind the `use_alloc` feature.
@@ -32,6 +35,8 @@ Iterators are [lazy](https://doc.rust-lang.org/std/iter/index.html#laziness):
- structs of iterator adaptors should have `#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]` ;
- structs of iterators should have `#[must_use = "iterators are lazy and do nothing unless consumed"]`.

Those behaviors are **tested** in `tests/laziness.rs`.

## Specialize `Iterator` methods
It might be more performant to specialize some methods.
However, each specialization should be thoroughly tested.
@@ -63,6 +68,9 @@ Additionally,

An adaptor might use the inner iterator specializations for its own specializations.

They are **tested** in `tests/specializations.rs` and **benchmarked** in `benches/specializations.rs`
(build those benchmarks is slow so you might want to temporarily remove the ones you do not want to measure).

## Additional implementations
### The [`Debug`](https://doc.rust-lang.org/std/fmt/trait.Debug.html) implementation
All our iterators should implement `Debug`.
@@ -159,6 +167,8 @@ The conditions on which it should be implemented are usually the ones from the `
### When to implement [`itertools::PeekingNext`](https://docs.rs/itertools/latest/itertools/trait.PeekingNext.html)
TODO

This is currently **tested** in `tests/test_std.rs`.

## About lending iterators
TODO

0 comments on commit d8c785f

Please sign in to comment.