Skip to content

Commit

Permalink
Fixed TypeWitnessTypeArg impl for BoolWitG (#14)
Browse files Browse the repository at this point in the history
Bumped version to 1.10.1, fixed TypeWitnessTypeArg impl of BoolWitG

Added doc example to BoolWitG showing where it'd be used over BoolWit

Update Changelog
  • Loading branch information
rodrimati1992 authored Nov 26, 2024
1 parent d824f85 commit 68c4bb0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "typewit"
version = "1.10.0"
version = "1.10.1"
authors = ["rodrimati1992 <[email protected]>"]
rust-version = "1.57.0"
edition = "2021"
Expand Down
6 changes: 5 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ This is the changelog, summarising changes in each version(some minor changes ma

# 1.0

### 1.10.1

Fixed `TypeWitnessTypeArg` impl for `BoolWitG`, it was overconstrained in a way that made `HasTypeWitness<BoolWitG<T>>` not work as a bound.

### 1.10.0

Added `typewit::const_marker::BoolWitG` enum
Expand Down Expand Up @@ -239,4 +243,4 @@ Declared these crate features:
- `mut_refs`
- `nightly_mut_refs`

Set the Minimum Supported Rust Version to 1.61.0
Set the Minimum Supported Rust Version to 1.61.0
25 changes: 23 additions & 2 deletions src/const_marker/boolwit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,27 @@ pub type BoolWit<const B: bool> = BoolWitG<Bool<B>>;
/// Use this over [`BoolWit`] if you want to write a [`HasTypeWitness`] bound
/// and adding a `const B: bool` parameter would be impossible.
///
/// # Example
///
/// This basic example demonstrates where `BoolWitG` would be used instead of `BoolWit`.
///
/// ```rust
/// use typewit::const_marker::{Bool, BoolWitG};
/// use typewit::HasTypeWitness;
///
///
/// trait Boolean: Sized + HasTypeWitness<BoolWitG<Self>> {
/// type Not: Boolean<Not = Self>;
/// }
///
/// impl Boolean for Bool<true> {
/// type Not = Bool<false>;
/// }
///
/// impl Boolean for Bool<false> {
/// type Not = Bool<true>;
/// }
/// ```
///
/// [`HasTypeWitness`]: crate::HasTypeWitness
pub enum BoolWitG<B> {
Expand All @@ -197,8 +218,8 @@ impl<const B: bool> Debug for BoolWitG<Bool<B>> {
}
}

impl<const B: bool> TypeWitnessTypeArg for BoolWitG<Bool<B>> {
type Arg = Bool<B>;
impl<B> TypeWitnessTypeArg for BoolWitG<B> {
type Arg = B;
}

impl<const B: bool> MakeTypeWitness for BoolWitG<Bool<B>> {
Expand Down

0 comments on commit 68c4bb0

Please sign in to comment.