From b90267e9492858c4b6adb18a23b9def1b62b2f51 Mon Sep 17 00:00:00 2001 From: Jannis Harder Date: Thu, 3 Oct 2024 15:27:16 +0200 Subject: [PATCH] lit: Cleanup and missing docs --- ir/src/var.rs | 2 +- lit/src/lib.rs | 10 ++++++---- lit/src/pol.rs | 28 ++++++---------------------- 3 files changed, 13 insertions(+), 27 deletions(-) diff --git a/ir/src/var.rs b/ir/src/var.rs index 4166839..98b72e8 100644 --- a/ir/src/var.rs +++ b/ir/src/var.rs @@ -1,2 +1,2 @@ //! Numeric identifiers for variables and Boolean literals -pub use imctk_lit::{lit::Lit, pol::Pol, var::Var}; +pub use imctk_lit::{Lit, Pol, Var}; diff --git a/lit/src/lib.rs b/lit/src/lib.rs index cb78b9f..c3906d7 100644 --- a/lit/src/lib.rs +++ b/lit/src/lib.rs @@ -1,6 +1,8 @@ //! Numeric identifiers for variables and Boolean literals -#![allow(missing_docs, dead_code)] // FIXME prototyping +mod lit; +mod pol; +mod var; -pub mod lit; -pub mod pol; -pub mod var; +pub use lit::Lit; +pub use pol::{Negate, NegateInPlace, Pol}; +pub use var::Var; diff --git a/lit/src/pol.rs b/lit/src/pol.rs index e48f534..d1bbf2b 100644 --- a/lit/src/pol.rs +++ b/lit/src/pol.rs @@ -156,33 +156,23 @@ impl ops::Not for &'_ Pol { } } +/// Subtrait of `ops::Not` and `ops::BitXor` for types that support Boolean negation. +/// +/// Types that implement `Negate` and `Clone` should also implement `Negate` for references. pub trait Negate: Sized + ops::Not::Negated> + ops::BitXor::Negated> { // Not called Output as that's ambiguous with the supertrait's Output + /// The common output type when invoking the `!` or `^` operator. type Negated; - - #[inline(always)] - fn negate(self) -> ::Negated - where - Self: Sized, - { - !self - } - - #[inline(always)] - fn apply_pol(self, pol: Pol) -> ::Negated { - self ^ pol - } } +/// Subtrait of `Negate` and `ops::BitXorAssign` for types that support in-place Boolean negation. pub trait NegateInPlace: Negate + ops::BitXorAssign { + /// Performs `ops::Not::not` in-place. fn negate_in_place(&mut self); - fn apply_pol_in_place(&mut self, pol: Pol) { - *self ^= pol; - } } impl ops::BitXorAssign for u64 { @@ -196,15 +186,9 @@ impl Negate for u64 { } impl NegateInPlace for u64 { - #[inline(always)] fn negate_in_place(&mut self) { *self = !*self; } - - #[inline(always)] - fn apply_pol_in_place(&mut self, pol: Pol) { - *self ^= 0 ^ pol; - } } impl Negate for &u64 {