Skip to content

Commit

Permalink
Export as few extra modules as possible
Browse files Browse the repository at this point in the history
  • Loading branch information
sffc committed Oct 13, 2020
1 parent 0a57a3e commit b1bcf91
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
5 changes: 4 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,14 @@ extern crate std;
#[cfg(all(not(feature = "std"), not(test)))]
extern crate core as std;

pub mod macros;
mod macros;
mod tinystr16;
mod tinystr4;
mod tinystr8;

/// Re-export of the low-level tinystr_macros crate, required by the macros.
pub use tinystr_macros as raw_macros;

#[cfg(any(feature = "std", feature = "alloc"))]
mod tinystrauto;

Expand Down
15 changes: 3 additions & 12 deletions src/macros.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/// Re-export of the low-level tinystr_macros crate.
pub use tinystr_macros;

/// Macro to create a const TinyStr4, validated with zero runtime cost.
///
/// The argument must be a string literal:
Expand All @@ -18,9 +15,7 @@ pub use tinystr_macros;
#[macro_export]
macro_rules! tinystr4 {
($s:literal) => {
unsafe {
$crate::TinyStr4::new_unchecked($crate::macros::tinystr_macros::u32_from_bytes!($s))
}
unsafe { $crate::TinyStr4::new_unchecked($crate::raw_macros::u32_from_bytes!($s)) }
};
}

Expand Down Expand Up @@ -49,9 +44,7 @@ fn test_tinystr4() {
#[macro_export]
macro_rules! tinystr8 {
($s:literal) => {
unsafe {
$crate::TinyStr8::new_unchecked($crate::macros::tinystr_macros::u64_from_bytes!($s))
}
unsafe { $crate::TinyStr8::new_unchecked($crate::raw_macros::u64_from_bytes!($s)) }
};
}

Expand Down Expand Up @@ -80,9 +73,7 @@ fn test_tinystr8() {
#[macro_export]
macro_rules! tinystr16 {
($s:literal) => {
unsafe {
$crate::TinyStr16::new_unchecked($crate::macros::tinystr_macros::u128_from_bytes!($s))
}
unsafe { $crate::TinyStr16::new_unchecked($crate::raw_macros::u128_from_bytes!($s)) }
};
}

Expand Down

0 comments on commit b1bcf91

Please sign in to comment.