Skip to content

Commit

Permalink
Merge pull request #417 from newAM/box-case
Browse files Browse the repository at this point in the history
Add test for box_pool with CamelCase types
  • Loading branch information
Dirbaio committed Nov 22, 2023
2 parents 7cd2625 + 23b9219 commit a09fe68
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Fixed

- Fixed clippy lints.
- Fixed `box_pool!` emitting clippy lints for `CamelCase` and `SNAKE_CASE`.

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

Expand Down
9 changes: 9 additions & 0 deletions src/pool/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,14 @@ use super::treiber::{NonNullPtr, Stack, UnionNode};
#[macro_export]
macro_rules! box_pool {
($name:ident: $data_type:ty) => {
#[allow(non_camel_case_types)]
pub struct $name;

impl $crate::pool::boxed::BoxPool for $name {
type Data = $data_type;

fn singleton() -> &'static $crate::pool::boxed::BoxPoolImpl<$data_type> {
#[allow(non_upper_case_globals)]
static $name: $crate::pool::boxed::BoxPoolImpl<$data_type> =
$crate::pool::boxed::BoxPoolImpl::new();

Expand Down Expand Up @@ -555,4 +557,11 @@ mod tests {
assert!(once.is_ok());
assert!(twice.is_ok());
}

#[test]
fn box_pool_case() {
// https://github.com/rust-embedded/heapless/issues/411
box_pool!(CamelCaseType: u128);
box_pool!(SCREAMING_SNAKE_CASE_TYPE: u128);
}
}

0 comments on commit a09fe68

Please sign in to comment.