Skip to content

Commit

Permalink
Merge pull request #40 from chrysn-pull-requests/add-usize
Browse files Browse the repository at this point in the history
Add restore-state-usize
  • Loading branch information
Dirbaio authored Oct 22, 2023
2 parents 84b3a79 + d9ba95f commit 6325940
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ restore-state-u8 = []
restore-state-u16 = []
restore-state-u32 = []
restore-state-u64 = []
restore-state-usize = []
14 changes: 12 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,27 @@ impl<'cs> CriticalSection<'cs> {
all(feature = "restore-state-bool", feature = "restore-state-u16"),
all(feature = "restore-state-bool", feature = "restore-state-u32"),
all(feature = "restore-state-bool", feature = "restore-state-u64"),
all(feature = "restore-state-bool", feature = "restore-state-usize"),
all(feature = "restore-state-u8", feature = "restore-state-u16"),
all(feature = "restore-state-u8", feature = "restore-state-u32"),
all(feature = "restore-state-u8", feature = "restore-state-u64"),
all(feature = "restore-state-u8", feature = "restore-state-usize"),
all(feature = "restore-state-u16", feature = "restore-state-u32"),
all(feature = "restore-state-u16", feature = "restore-state-u64"),
all(feature = "restore-state-u16", feature = "restore-state-usize"),
all(feature = "restore-state-u32", feature = "restore-state-u64"),
all(feature = "restore-state-u32", feature = "restore-state-usize"),
all(feature = "restore-state-u64", feature = "restore-state-usize"),
))]
compile_error!("You must set at most one of these Cargo features: restore-state-none, restore-state-bool, restore-state-u8, restore-state-u16, restore-state-u32, restore-state-u64");
compile_error!("You must set at most one of these Cargo features: restore-state-none, restore-state-bool, restore-state-u8, restore-state-u16, restore-state-u32, restore-state-u64, restore-state-usize");

#[cfg(not(any(
feature = "restore-state-bool",
feature = "restore-state-u8",
feature = "restore-state-u16",
feature = "restore-state-u32",
feature = "restore-state-u64"
feature = "restore-state-u64",
feature = "restore-state-usize"
)))]
type RawRestoreStateInner = ();

Expand All @@ -87,6 +93,9 @@ type RawRestoreStateInner = u32;
#[cfg(feature = "restore-state-u64")]
type RawRestoreStateInner = u64;

#[cfg(feature = "restore-state-usize")]
type RawRestoreStateInner = usize;

// We have RawRestoreStateInner and RawRestoreState so that we don't have to copypaste the docs 5 times.
// In the docs this shows as `pub type RawRestoreState = u8` or whatever the selected type is, because
// the "inner" type alias is private.
Expand All @@ -100,6 +109,7 @@ type RawRestoreStateInner = u64;
/// - `restore-state-u16`
/// - `restore-state-u32`
/// - `restore-state-u64`
/// - `restore-state-usize`
///
/// See [`RestoreState`].
///
Expand Down

0 comments on commit 6325940

Please sign in to comment.