https://github.com/llogiq/ternary
Kleene logic in Rust's type system
https://github.com/llogiq/ternary
Last synced: about 1 month ago
JSON representation
Kleene logic in Rust's type system
- Host: GitHub
- URL: https://github.com/llogiq/ternary
- Owner: llogiq
- License: mit
- Created: 2015-12-17T19:37:58.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-02-26T23:11:22.000Z (about 9 years ago)
- Last Synced: 2025-03-14T12:04:37.372Z (2 months ago)
- Language: Rust
- Size: 525 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Kleene logic within Rust's type system
[](https://travis-ci.org/llogiq/ternary)
[](https://crates.io/crates/ternary)
[](https://coveralls.io/github/llogiq/ternary?branch=master)
[](LICENSE)Values are `True`, `False` and `Unknown`. Operations are `Not`, `BitAnd`
and `BitOr` from `std::ops`. There is also the `Ternary` enum which
represents the values at runtime and the `ToTernary` trait that adds the
`to_ternary()` methods to our value types.For more information read the [API documentation](http://llogiq.github.io/ternary)
Examples:
`Same` and `Not`
```
use ternary::{True, False, Unknown, Same};
use std::ops::Not;
type NotTrue = <::Output as Same>::Output;
type NotFalse = <::Output as Same>::Output;
type NotUnknown = <::Output as Same>::Output;
```Transforming Values to Runtime, `BitAnd` and `BitOr`
```
assert_eq!(Ternary::T, >::Output>>::Output::to_ternary());
```To use it, add `ternary = "0.1.0"` to your dependencies.