Skip to content

Commit b995a15

Browse files
committed
Merge remote-tracking branch 'upstream/main' into remove-doc-auto-cfg-feature
2 parents e0e6546 + bbe988d commit b995a15

36 files changed

+4629
-1660
lines changed

.github/workflows/build.yml

Lines changed: 56 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99

1010
env:
1111
CARGO_TERM_COLOR: always
12-
RUSTFLAGS: '-D warnings'
12+
RUSTFLAGS: "-D warnings"
1313

1414
jobs:
1515
# Run MIRI tests on nightly
@@ -48,7 +48,7 @@ jobs:
4848
components: miri
4949

5050
- name: Run miri
51-
run: MIRIFLAGS=-Zmiri-ignore-leaks cargo miri test
51+
run: MIRIFLAGS=-Zmiri-ignore-leaks cargo miri test --features="alloc,defmt,mpmc_large,portable-atomic-critical-section,serde,ufmt,bytes,zeroize"
5252

5353
# Run cargo test
5454
test:
@@ -84,7 +84,7 @@ jobs:
8484
toolchain: stable
8585

8686
- name: Run cargo test
87-
run: cargo test
87+
run: cargo test --features="alloc,defmt,mpmc_large,portable-atomic-critical-section,serde,ufmt,bytes,zeroize"
8888

8989
# Run cargo fmt --check
9090
style:
@@ -163,18 +163,26 @@ jobs:
163163

164164
- name: cargo check
165165
run: |
166-
cargo check --target=${{ matrix.target }}
167-
cargo check --target=${{ matrix.target }} --features="portable-atomic-critical-section"
168-
cargo check --target=${{ matrix.target }} --features="ufmt serde defmt-03 mpmc_large"
166+
cargo check --target="${target}"
167+
cargo check --target="${target}" --features="alloc"
168+
169+
# Needs native atomics, since `bytes` doesn't support `portable-atomic`.
170+
if [ "${target}" != "riscv32imc-unknown-none-elf" ] && [ "${target}" != "thumbv6m-none-eabi" ]; then
171+
cargo check --target="${target}" --features="bytes"
172+
fi
173+
174+
cargo check --target="${target}" --features="defmt"
175+
cargo check --target="${target}" --features="mpmc_large"
176+
cargo check --target="${target}" --features="portable-atomic-critical-section"
177+
cargo check --target="${target}" --features="serde"
178+
cargo check --target="${target}" --features="ufmt"
179+
cargo check --target="${target}" --features="zeroize"
180+
env:
181+
target: ${{ matrix.target }}
169182

170183
doc:
171184
name: doc
172185
runs-on: ubuntu-latest
173-
strategy:
174-
matrix:
175-
target:
176-
- x86_64-unknown-linux-gnu
177-
- thumbv7m-none-eabi
178186
steps:
179187
- name: Checkout
180188
uses: actions/checkout@v4
@@ -201,14 +209,40 @@ jobs:
201209
${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }}
202210
${{ runner.OS }}-build-
203211
204-
- name: Install nightly Rust with target (${{ matrix.target }})
212+
- name: Get metadata
213+
id: metadata
214+
run: |
215+
set -euo pipefail
216+
217+
docsrs_metadata="$(cargo metadata --format-version 1 | jq '.packages[] | select(.name == "heapless") | .metadata.docs.rs')"
218+
features=($(jq --raw-output '.features[]' <<< "${docsrs_metadata}"))
219+
rustdocflags=(-D warnings --cfg docsrs $(jq --raw-output '.["rustdoc-args"][]' <<< "${docsrs_metadata}"))
220+
targets=($(jq --raw-output '.targets[]' <<< "${docsrs_metadata}"))
221+
222+
echo "features=${features[*]}" >> "${GITHUB_OUTPUT}"
223+
echo "rustdocflags=${rustdocflags[*]}" >> "${GITHUB_OUTPUT}"
224+
echo "targets=${targets[*]}" >> "${GITHUB_OUTPUT}"
225+
226+
- name: Install nightly Rust with targets (${{ steps.metadata.outputs.targets }})
205227
uses: dtolnay/rust-toolchain@nightly
206228
with:
207-
targets: ${{ matrix.target }}
229+
targets: ${{ steps.metadata.outputs.targets }}
208230

209231
- name: cargo rustdoc
210-
env: {"RUSTDOCFLAGS": "-D warnings --cfg docsrs"}
211-
run: cargo rustdoc --target=${{ matrix.target }} --features="ufmt serde defmt-03 mpmc_large portable-atomic-critical-section"
232+
run: |
233+
set -euo pipefail
234+
235+
targets=(${targets})
236+
237+
for target in "${targets[@]}"; do
238+
set -x
239+
cargo rustdoc --target "${target}" --features "${features}"
240+
set +x
241+
done
242+
env:
243+
features: ${{ steps.metadata.outputs.features }}
244+
RUSTDOCFLAGS: ${{ steps.metadata.outputs.rustdocflags }}
245+
targets: ${{ steps.metadata.outputs.targets }}
212246

213247
# Run cpass tests
214248
testcpass:
@@ -255,7 +289,7 @@ jobs:
255289
targets: ${{ matrix.target }}
256290

257291
- name: cargo test
258-
run: cargo test --test cpass --target=${{ matrix.target }} --features=serde ${{ matrix.buildtype }}
292+
run: cargo test --test cpass --target=${{ matrix.target }} ${{ matrix.buildtype }}
259293

260294
# Run test suite for UI
261295
testtsan:
@@ -312,6 +346,9 @@ jobs:
312346
testcfail:
313347
name: testcfail
314348
runs-on: ubuntu-latest
349+
env:
350+
RUSTFLAGS: -D warnings
351+
MSRV: 1.87.0
315352
defaults:
316353
run:
317354
working-directory: cfail
@@ -341,7 +378,9 @@ jobs:
341378
${{ runner.OS }}-build-
342379
343380
- name: Install Rust
344-
uses: dtolnay/rust-toolchain@stable
381+
uses: dtolnay/rust-toolchain@master
382+
with:
383+
toolchain: ${{ env.MSRV }}
345384

346385
- name: Run cargo
347386
run: cargo run

CHANGELOG.md

Lines changed: 99 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,45 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
- Minor fixes to module docs.
11+
- Make MSRV of 1.87.0 explicit.
12+
- Implement `Default` for `CapacityError`.
13+
- Implement `defmt::Format` for `CapacityError`.
14+
- Implement `TryFrom` for `Deque` from array.
15+
- Switch from `serde` to `serde_core` for enabling faster compilations.
16+
- Implement `Zeroize` trait for all data structures with the `zeroize` feature to securely clear sensitive data from memory.
17+
18+
## [v0.9.1] - 2025-08-19
19+
20+
### Added
21+
22+
- Added `String::insert` and `String::insert_str`.
23+
24+
### Changed
25+
26+
- `bytes::BufMut` is now implemented on `VecInner`.
27+
- Removed generic from `history_buf::OldestOrdered`.
28+
- Made `LenType` opt-in.
29+
- Minor fixes to `pool::boxed` docs.
30+
- Add missing `Debug` derive to `vec::IntoIter`.
31+
- Removed generic from `spsc::Consumer`, `spsc::Producer` and `spsc::Iter`.
32+
33+
### Fixed
34+
35+
- CI now uses flags specified in `Cargo.toml` for `rustdoc` tests.
36+
- Fixed clippy lints.
37+
- Fixed the memory layout of the internal `UnionNode<T>` type, fixing possible Undefined Behaviour.
38+
39+
### Removed
40+
41+
- Removed invalid `bytes::Buf` implementation.
42+
- Removed `DefaultLenType` struct.
43+
44+
## [v0.9.0] - 2025-04-28 [YANKED]
45+
1046
### Added
1147

48+
- Added `bytes::Buf` and `bytes::BufMut` implementations for `Vec`.
1249
- Added `format` macro.
1350
- Added `String::from_utf16`.
1451
- Added `is_full`, `recent_index`, `oldest`, and `oldest_index` to `HistoryBuffer`
@@ -40,13 +77,67 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
4077
- Added implementation of `Borrow` and `BorrowMut` for `String` and `Vec`.
4178
- Added `Deque::{swap, swap_unchecked, swap_remove_front, swap_remove_back}`.
4279
- Make `String::from_utf8_unchecked` const.
80+
- Implemented `PartialEq` and `Eq` for `Deque`.
81+
- Added `alloc` feature to enable `alloc`-Vec interoperability.
82+
- Added `TryFrom<alloc::vec::Vec>` impl for `Vec`.
83+
- Added `TryFrom<Vec>` impl for `alloc::vec::Vec`.
84+
- Added `truncate` to `IndexMap`.
85+
- Added `get_index` and `get_index_mut` to `IndexMap`.
86+
- Added `String::uDisplay`.
87+
- Added `CString`.
88+
- Added `LenT` generic to `Vec<T, N>` and `VecView<T>` to save memory when using a sane capacity value.
89+
- Added the `index_set` module.
90+
- Added the `index_map` module.
91+
- Migrated `Idx` generic for `SortedLinkedList` to use the new `LenType` trait, allowing for `Idx` inference.
92+
- Added similar `LenT` generic to `String`.
93+
- Optimize size of zero capacity `Vec<T, 0>` to be 0 bytes
4394

4495
### Changed
4596

97+
- Updated defmt from 0.3 to 1.0.1
98+
- Changed the feature name from `defmt-03` to `defmt`.
99+
- Changed the error type of these methods from `()` to `CapacityError`.
100+
- `String::push_str`
101+
- `String::push`
102+
- `Vec::extend_from_slice`
103+
- `Vec::from_slice`
104+
- `Vec::resize_default`
105+
- `Vec::resize`
106+
- Renamed `FromUtf16Error::DecodeUtf16Error` to `FromUtf16Error::DecodeUtf16`.
46107
- Changed `stable_deref_trait` to a platform-dependent dependency.
108+
- Changed `SortedLinkedList::pop` return type from `Result<T, ()>` to `Option<T>` to match `std::vec::pop`.
109+
- `Vec::capacity` is no longer a `const` function.
110+
- Relaxed bounds on `PartialEq` for `IndexMap` from `V: Eq` to `V1: PartialEq<V2>`.
111+
- Relaxed bounds on `PartialEq` for `LinearMap` from `V: PartialEq` to `V1: PartialEq<V2>`.
112+
- The `FnvIndexSet` type is now inside the `index_set` module.
113+
- The `IndexSetIter` type is now inside the `index_set` module and has been renamed to `Iter`.
114+
- The `Bucket` type is now inside the `index_map` module.
115+
- The `Entry` type is now inside the `index_map` module.
116+
- The `FnvIndexMap` type is now inside the `index_map` module.
117+
- The `IndexMapIter` type is now inside the `index_map` module and has been renamed to `Iter`.
118+
- The `IndexMapIterMut` type is now inside the `index_map` module and has been renamed to `IterMut`.
119+
- The `IndexMapKeys` type is now inside the `index_map` module and has been renamed to `Keys`.
120+
- The `OccupiedEntry` type is now inside the `index_map` module.
121+
- The `Pos` type is now inside the `index_map` module.
122+
- The `VacantEntry` type is now inside the `index_map` module.
123+
- The `VacantEntry` type is now inside the `index_map` module.
124+
- The `IndexMapValues` type is now inside the `index_map` module and has been renamed to `Values`.
125+
- The `IndexMapValuesMut` type is now inside the `index_map` module and has been renamed to `ValuesMut`.
126+
- The `histbuf` module has been renamed to `history_buf`.
127+
- The `HistoryBuffer` type has been renamed to `HistoryBuf`.
128+
- The `HistoryBufferView` type has been renamed to `HistoryBufView`.
129+
- The `OwnedHistBufStorage` type has been renamed to `OwnedHistoryBufStorage`.
130+
- The `ViewHistBufStorage` type has been renamed to `ViewHistoryBufStorage`.
131+
- The `MpMcQueue` type has been renamed to `Queue`.
132+
- The `MpMcQueueView` type has been renamed to `QueueView`.
133+
- The `MpMcQueueInner` type has been renamed to `QueueInner`.
134+
- Remove `Q*` type aliases for `MpMcQueue`, and rename it to just `Queue`
135+
- Changed `Queue::split` to be `const`.
47136

48137
### Fixed
49138

139+
- Fixed bug in `IndexMap::truncate` that left the map in an inconsistent state.
140+
- Fixed compilation on `thumbv6m-none-eabi` without `portable-atomic` feature.
50141
- Fixed clippy lints.
51142
- Fixed `{arc,box,object}_pool!` emitting clippy lints.
52143
- Fixed the list of implemented data structures in the crate docs, by adding `Deque`,
@@ -58,6 +149,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
58149

59150
- `doc_auto_cfg` feature which was merged into `doc_cfg`. Presence of the feature led to doc
60151
build failures on nightly.
152+
- `Vec::storage_capacity` has been removed and `Vec::capacity` must be used instead.
153+
- Removed `sorted_linked_list::Iter` and `sorted_linked_list::IterInner`.
154+
- Removed `sorted_linked_list::FindMut` and `sorted_linked_list::FindMutInner`.
155+
- The `Q2`, `Q4`, `Q8`, `Q16`, `Q32` and `Q64` aliases for `MpMcQueue` have been removed.
61156

62157
## [v0.8.0] - 2023-11-07
63158

@@ -94,6 +189,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
94189
- `ufmt-impl` is now `ufmt`
95190
- `cas` is removed, atomic polyfilling is now opt-in via the `portable-atomic` feature.
96191
- `Vec::as_mut_slice` is now a public method.
192+
- `ufmt` functions are annotated with `inline`.
97193

98194
### Fixed
99195

@@ -615,7 +711,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
615711

616712
- Initial release
617713

618-
[Unreleased]: https://github.com/rust-embedded/heapless/compare/v0.8.0...HEAD
714+
[Unreleased]: https://github.com/rust-embedded/heapless/compare/v0.9.1...HEAD
715+
[v0.9.1]: https://github.com/rust-embedded/heapless/compare/v0.9.0...v0.9.1
716+
[v0.9.0]: https://github.com/rust-embedded/heapless/compare/v0.8.0...v0.9.0
619717
[v0.8.0]: https://github.com/rust-embedded/heapless/compare/v0.7.16...v0.8.0
620718
[v0.7.16]: https://github.com/rust-embedded/heapless/compare/v0.7.15...v0.7.16
621719
[v0.7.15]: https://github.com/rust-embedded/heapless/compare/v0.7.14...v0.7.15

Cargo.toml

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,91 @@
11
[package]
22
authors = [
3-
"Jorge Aparicio <[email protected]>",
4-
"Per Lindgren <[email protected]>",
5-
"Emil Fresk <[email protected]>",
3+
"Jorge Aparicio <[email protected]>",
4+
"Per Lindgren <[email protected]>",
5+
"Emil Fresk <[email protected]>",
66
]
77
categories = ["data-structures", "no-std"]
88
description = "`static` friendly data structures that don't require dynamic memory allocation"
99
documentation = "https://docs.rs/heapless"
1010
edition = "2021"
11+
rust-version = "1.87"
1112
keywords = ["static", "no-heap"]
1213
license = "MIT OR Apache-2.0"
1314
name = "heapless"
1415
repository = "https://github.com/rust-embedded/heapless"
15-
version = "0.8.0"
16+
version = "0.9.1"
1617

1718
[features]
19+
bytes = ["dep:bytes"]
20+
1821
# Enable polyfilling of atomics via `portable-atomic`.
1922
# `portable-atomic` polyfills some functionality by default, but to get full atomics you must
2023
# enable one of its features to tell it how to do it. See `portable-atomic` documentation for details.
2124
portable-atomic = ["dep:portable-atomic"]
2225

2326
# Enable polyfilling of atomics via portable-atomic, using critical section for locking
24-
portable-atomic-critical-section = ["dep:portable-atomic", "portable-atomic", "portable-atomic?/critical-section"]
27+
portable-atomic-critical-section = [
28+
"dep:portable-atomic",
29+
"portable-atomic",
30+
"portable-atomic?/critical-section",
31+
]
2532

2633
# Enable polyfilling of atomics via portable-atomic, using disabling interrupts for locking.
2734
# WARNING: this is only sound for single-core bare-metal privileged-mode targets!
28-
portable-atomic-unsafe-assume-single-core = ["dep:portable-atomic", "portable-atomic", "portable-atomic?/unsafe-assume-single-core"]
35+
portable-atomic-unsafe-assume-single-core = [
36+
"dep:portable-atomic",
37+
"portable-atomic",
38+
"portable-atomic?/unsafe-assume-single-core",
39+
]
2940

3041
# implement serde traits.
31-
serde = ["dep:serde"]
42+
serde = ["dep:serde_core"]
3243

3344
# implement ufmt traits.
34-
ufmt = ["dep:ufmt-write"]
45+
ufmt = ["dep:ufmt", "dep:ufmt-write"]
3546

36-
# Implement defmt::Format from defmt v0.3
37-
defmt-03 = ["dep:defmt"]
47+
# Implement `defmt::Format`.
48+
defmt = ["dep:defmt"]
49+
50+
# Implement `zeroize::Zeroize` trait.
51+
zeroize = ["dep:zeroize"]
3852

3953
# Enable larger MPMC sizes.
4054
mpmc_large = []
4155

56+
# Implement some alloc Vec interoperability
57+
alloc = []
58+
4259
nightly = []
4360

4461
[dependencies]
62+
bytes = { version = "1", default-features = false, optional = true }
4563
portable-atomic = { version = "1.0", optional = true }
4664
hash32 = "0.3.0"
47-
serde = { version = "1", optional = true, default-features = false }
65+
serde_core = { version = "1", optional = true, default-features = false }
66+
ufmt = { version = "0.2", optional = true }
4867
ufmt-write = { version = "0.1", optional = true }
49-
defmt = { version = ">=0.2.0,<0.4", optional = true }
68+
defmt = { version = "1.0.1", optional = true }
69+
zeroize = { version = "1.8", optional = true, default-features = false, features = ["derive"] }
5070

5171
# for the pool module
5272
[target.'cfg(any(target_arch = "arm", target_pointer_width = "32", target_pointer_width = "64"))'.dependencies]
5373
stable_deref_trait = { version = "1", default-features = false }
5474

5575
[dev-dependencies]
56-
ufmt = "0.2"
76+
critical-section = { version = "1.1", features = ["std"] }
5777
static_assertions = "1.1.0"
5878

5979
[package.metadata.docs.rs]
60-
features = ["ufmt", "serde", "defmt-03", "mpmc_large", "portable-atomic-critical-section"]
80+
features = [
81+
"bytes",
82+
"ufmt",
83+
"serde",
84+
"defmt",
85+
"mpmc_large",
86+
"portable-atomic-critical-section",
87+
"alloc",
88+
]
6189
# for the pool module
6290
targets = ["i686-unknown-linux-gnu"]
6391
rustdoc-args = ["--cfg", "docsrs"]

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ Licensed under either of
3232

3333
at your option.
3434

35+
## MSRV Policy
36+
37+
This crate is guaranteed to compile with the latest two stable releases of Rust. For example, if the
38+
latest stable Rust release is 1.70, then this crate is guaranteed to compile with Rust 1.69 and 1.70.
39+
3540
## Contribution
3641

3742
Unless you explicitly state otherwise, any contribution intentionally submitted

0 commit comments

Comments
 (0)