Skip to content

Commit 52f55af

Browse files
committed
Move get_heap_threshold to inline module
1 parent 48a9d8b commit 52f55af

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

src/inline.rs

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ pub(crate) trait TypeSize {}
1010
#[cfg(not(feature = "typesize"))]
1111
impl<T> TypeSize for T {}
1212

13+
pub(crate) const fn get_heap_threshold<LenT>() -> usize {
14+
std::mem::size_of::<usize>() + std::mem::size_of::<LenT>() - 1
15+
}
16+
1317
#[cfg_attr(feature = "typesize", derive(typesize::derive::TypeSize))]
1418
#[derive(Clone)]
1519
pub(crate) struct InlineString<StrRepr: Copy + AsRef<[u8]> + AsMut<[u8]> + Default + TypeSize> {

src/length.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use crate::inline::get_heap_threshold;
2+
13
mod sealed {
24
pub trait Sealed {}
35
impl Sealed for u8 {}
@@ -86,10 +88,6 @@ impl TryFrom<InvalidLength<u8>> for InvalidStrLength {
8688
}
8789
}
8890

89-
pub(crate) const fn get_heap_threshold<LenT>() -> usize {
90-
std::mem::size_of::<usize>() + std::mem::size_of::<LenT>() - 1
91-
}
92-
9391
/// A sealed trait to represent valid lengths for a [`FixedArray`].
9492
///
9593
/// This is implemented on `u32` for non-16 bit platforms, and `u16` on all platforms.

src/string.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use std::{cmp::PartialEq, fmt::Write as _, hash::Hash};
22

33
use crate::{
44
array::FixedArray,
5-
inline::InlineString,
6-
length::{get_heap_threshold, InvalidStrLength, SmallLen, ValidLength},
5+
inline::{get_heap_threshold, InlineString},
6+
length::{InvalidStrLength, SmallLen, ValidLength},
77
};
88

99
#[cfg_attr(feature = "typesize", derive(typesize::derive::TypeSize))]

0 commit comments

Comments
 (0)