-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sketches out manual test using new
BooleanSemiring
- Loading branch information
Showing
4 changed files
with
104 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use std::{fmt::Display, ops}; | ||
|
||
use super::semiring_traits::Semiring; | ||
|
||
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)] | ||
pub struct BooleanSemiring(pub bool); | ||
|
||
impl Semiring for BooleanSemiring { | ||
fn one() -> Self { | ||
BooleanSemiring(true) | ||
} | ||
|
||
fn zero() -> Self { | ||
BooleanSemiring(false) | ||
} | ||
} | ||
|
||
impl Display for BooleanSemiring { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
write!(f, "{}", self.0) | ||
} | ||
} | ||
|
||
impl ops::Add<BooleanSemiring> for BooleanSemiring { | ||
type Output = BooleanSemiring; | ||
|
||
fn add(self, rhs: BooleanSemiring) -> Self::Output { | ||
BooleanSemiring(self.0 || rhs.0) | ||
} | ||
} | ||
|
||
impl ops::Mul<BooleanSemiring> for BooleanSemiring { | ||
type Output = BooleanSemiring; | ||
|
||
fn mul(self, rhs: BooleanSemiring) -> Self::Output { | ||
BooleanSemiring(self.0 && rhs.0) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod boolean; | ||
pub mod expectation; | ||
pub mod finitefield; | ||
pub mod realsemiring; | ||
|