From 75c63d9645b0d6aa4164fb7a73f25bc15b34d280 Mon Sep 17 00:00:00 2001 From: David Roundy Date: Thu, 11 Apr 2024 12:43:19 -0700 Subject: [PATCH] add test confirming that `ArcIntern` is the size of `usize` --- benches/get_container.rs | 2 +- src/arc.rs | 9 +++++++++ src/arena.rs | 4 ++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/benches/get_container.rs b/benches/get_container.rs index a8b7e3a..36b5d41 100644 --- a/benches/get_container.rs +++ b/benches/get_container.rs @@ -1,6 +1,6 @@ //! This is a benchmark to demonstrate that cached types (`String`, `str` as of now) //! are faster than non-cached types because the lack of getting container from a dashmap. -//! +//! //! The results show a whopping 26% performance gain for short `ArcIntern`. use criterion::*; diff --git a/src/arc.rs b/src/arc.rs index 8121229..6a0f7bd 100644 --- a/src/arc.rs +++ b/src/arc.rs @@ -511,6 +511,15 @@ fn arc_has_niche() { std::mem::size_of::>>(), std::mem::size_of::(), ); + + assert_eq!( + std::mem::size_of::>(), + std::mem::size_of::(), + ); + assert_eq!( + std::mem::size_of::>>(), + std::mem::size_of::(), + ); } #[test] diff --git a/src/arena.rs b/src/arena.rs index 1123c41..90552ce 100644 --- a/src/arena.rs +++ b/src/arena.rs @@ -323,10 +323,10 @@ impl<'a, T: ?Sized> ArenaIntern<'a, T> { /// struct Bar { /// baz: String, /// } - /// + /// /// struct Foo<'a>(ArenaIntern<'a, Bar>); /// ``` - /// + /// /// The following code does not compile. /// ```compile_fail /// # use internment::ArenaIntern;