Skip to content

Commit

Permalink
Rename items around type-level booleans
Browse files Browse the repository at this point in the history
Renamed `type_level_bool` module to `_bool`.

Renamed `ToBool::Value` associated type to `ToBool::Bool`.
  • Loading branch information
nvzqz committed Dec 29, 2019
1 parent 87c22af commit 5cd37b0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
14 changes: 7 additions & 7 deletions src/type_level_bool.rs → src/bool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@ impl False {
}

pub trait ToBool: Sized {
type Value: Sized;
const TO_BOOL: Self::Value;
type Bool: Sized;
const TO_BOOL: Self::Bool;
}

impl ToBool for [(); 0] {
type Value = False;
const TO_BOOL: Self::Value = False;
type Bool = False;
const TO_BOOL: Self::Bool = False;
}

impl ToBool for [(); 1] {
type Value = True;
const TO_BOOL: Self::Value = True;
type Bool = True;
const TO_BOOL: Self::Bool = True;
}

/// Converts a `const bool` to a type-level boolean.
#[doc(hidden)]
#[macro_export]
macro_rules! to_bool {
($x:expr) => {
<[(); $x as usize] as $crate::type_level_bool::ToBool>::TO_BOOL
<[(); $x as usize] as $crate::_bool::ToBool>::TO_BOOL
};
}
16 changes: 11 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,6 @@ pub use proc_static_assertions::assert;
#[doc(hidden)]
pub extern crate core as _core;

#[doc(hidden)]
pub use type_level_bool::{True, False};

mod assert_cfg;
mod assert_eq_align;
mod assert_eq_size;
Expand All @@ -122,6 +119,15 @@ mod assert_trait;
mod assert_type;
mod const_assert;

/// This module should never be used publicly and is not part of this crate's semver requirements.
// Type-level booleans.
//
// This module should never be used publicly and is not part of this crate's
// semver requirements.
#[doc(hidden)]
#[path = "bool.rs"]
pub mod _bool;

// These types should also never be used publicly and are not part of this
// crate's semver requirements.
#[doc(hidden)]
pub mod type_level_bool;
pub use _bool::{False, True};

0 comments on commit 5cd37b0

Please sign in to comment.