zfc

Library for sets according to ZFC.
git clone https://git.philomathiclife.com/repos/zfc
Log | Files | Refs | README

commit 902fce37b8261a7468ff03afbe861434a2e2f3bf
parent 55d897303bea205e2d78b47743cf62ede692f7f1
Author: Zack Newman <zack@philomathiclife.com>
Date:   Wed, 18 Oct 2023 15:49:22 -0600

minor formatting and doc changes

Diffstat:
MCargo.toml | 2+-
Msrc/lib.rs | 19++++++++++---------
2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT OR Apache-2.0" name = "zfc" readme = "README.md" repository = "https://git.philomathiclife.com/repos/zfc/" -version = "0.3.0" +version = "0.3.1" [lib] name = "zfc" diff --git a/src/lib.rs b/src/lib.rs @@ -35,7 +35,7 @@ use core::fmt::{self, Display, Formatter}; use core::ops::{Range, RangeInclusive, Sub}; use num_bigint::BigUint; /// Represents the quantity of elements in a [`Set`]. -#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Clone, Eq, Hash, Ord, PartialEq, PartialOrd)] #[allow(clippy::exhaustive_enums)] pub enum Cardinality { /// The contained `BigUint` represents the quantity of elements in a finite `Set`. @@ -287,7 +287,7 @@ impl PartialOrd<BigUint> for Cardinality { /// [`BoundedCardinality`] from a pair of [`BigUint`]s /// or [`Cardinality`]s such that the upper bound /// is strictly less than the lower bound. -#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] pub struct BoundedErr; impl Display for BoundedErr { #[allow(clippy::min_ident_chars)] @@ -299,7 +299,7 @@ impl Display for BoundedErr { /// Error returned when attempting to create a /// [`Cardinality`] from a [`BoundedCardinality`] such that /// the lower bound is less than the upper bound. -#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] pub struct CardinalityErr; impl Display for CardinalityErr { #[allow(clippy::min_ident_chars)] @@ -311,7 +311,7 @@ impl Display for CardinalityErr { /// Contains a lower and upper bound /// [`Cardinality`] used to bound the cardinality /// of a [`Set`]. -#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Clone, Eq, Hash, Ord, PartialEq, PartialOrd)] pub struct BoundedCardinality { /// Lower bound. lower: Cardinality, @@ -519,9 +519,8 @@ pub trait Set { type Elem: Eq + ?Sized; /// Returns the cardinality of `self` if it is known exactly. /// - /// The following properties must be true: - /// * `self.cardinality().is_none()` ⇔ `self.bounded_cardinality().lower() < self.bounded_cardinality().upper()`. - /// * `self.cardinality().is_some()` ⇔ `self.cardinality().unwrap() == self.bounded_cardinality().lower()`. + /// The following property must be true: + /// * `self.cardinality().unwrap() == self.bounded_cardinality().lower()` ⇔ `self.bounded_cardinality().lower() == self.bounded_cardinality().upper()`. #[inline] fn cardinality(&self) -> Option<Cardinality> { let bound = self.bounded_cardinality(); @@ -761,6 +760,8 @@ use core::hash::{BuildHasher, Hash}; #[cfg(feature = "std")] use std::collections::HashSet; #[cfg(feature = "std")] +use std::error::Error; +#[cfg(feature = "std")] impl<T, S> Set for HashSet<T, S> where T: Eq + Hash, @@ -796,6 +797,6 @@ where } } #[cfg(feature = "std")] -impl std::error::Error for BoundedErr {} +impl Error for BoundedErr {} #[cfg(feature = "std")] -impl std::error::Error for CardinalityErr {} +impl Error for CardinalityErr {}