70: Implement Debug for `Queue`, `LinearMap` and `BinaryHeap` r=japaric a=XOSplicer
# Description
As pointed out in #56 the `fmt::Debug` implementation for those types is missing.
This PR implements them by passing their respective `Iterator` to the formatter.
# Open Questions
- Should `Debug` also be implemented for `spsc::Consumer` and `spsc::Producer`?
- Should the implementation for `BinaryHeap` respect the priority of the items in the heap?
Co-authored-by: Felix Stegmaier <stegmaier.felix@gmail.com>
Before, to achieve a capacity of 16 elements RingBuffer used an array of 17
elements under the hood. Now the same can be accomplished with an array of 16
elements.
This simplifies the bounds of RingBuffer but it's technically a breaking change.
This change adds an overhead of 1 cycle to the enqueue and dequeue operations.
This commit also documents that using capacities that are powers of two results
in better performance (modulo operations become shifts). This was not documented
before and due to the mismatch of capacity and array size a RB with capacity of
15 performed better than one with a capacity of 16.
43: Put all const functions behind a const-fn feature r=japaric a=XOSplicer
## Purpose
This PR introduces the `const-fn` feature gate, which when enabled makes most `new` methods `const`
and therefore usable for initializing `static` variables.
The idea was introduced in #40 with the purpose to come closer to targeting stable rust.
`const` functions are currently only available on rust nightly (tracking issue: [const fn tracking issue (RFC 911)](https://github.com/rust-lang/rust/issues/24111)).
In order to target stable rust this feature is made opt-in.
This feature is a **breaking change** as users of the library now need to explicitly enable it by changing their `Cargo.toml`:
```
...
[dependencies]
heapless = { version = "0.4.0", features = ["const-fn"] }
...
```
## Approach
The implementation of the feature mainly consist of the `const_fn!` macro, which takes a function with `const` modifier
and removes the modifier if the feature gate is not activated.
For the `const` functions a test is intoduced that checks if `static` variables can be initialized.
These tests are only active if the feature is active.
I have not found a way to make doc-test depend on a feature. Therefore some doc-tests are adapted, so that no static initialization is necessary.
The `ci/script.sh` is adapted to also tests with the `--all-feature` flag
## Future
When in the future the `const_fn` rust feature becomes stable, this feature gate **might become active by default**.
Closes#41 .
Co-authored-by: Felix <stegmaier.felix@gmail.com>
Co-authored-by: Felix Stegmaier <stegmaier.felix@gmail.com>
Co-authored-by: Felix Stegmaier <felix.stegmaier@hpe.com>