#![cfg_attr(unix, doc = include_str!("../README.md"))]
#![cfg_attr(windows, doc = include_str!("..\\README.md"))]
#![cfg_attr(
not(feature = "std"),
doc = "\n",
doc = "Note: This crate was built without its `std` feature and some premade items are \
unavailable, and so custom types must be provided and used with the items of the \
[`generic`] module, to have cycle-safety and/or deep-safety."
)]
#![cfg_attr(
all(not(feature = "std"), feature = "alloc"),
doc = "\n",
doc = "Note: This crate was built with its `alloc` feature, and so some premade items, \
that use the [`alloc`](https://doc.rust-lang.org/alloc/) crate, are available."
)]
#![no_std]
#![forbid(unsafe_code)]
#![warn(
// Groups
future_incompatible,
nonstandard_style,
rust_2018_compatibility, // unsure if needed with edition="2018"
rust_2018_idioms,
rust_2021_compatibility,
unused,
clippy::all,
clippy::pedantic,
clippy::restriction,
clippy::cargo,
// Individual lints not included in above groups and desired.
macro_use_extern_crate,
meta_variable_misuse,
// missing_copy_implementations,
// missing_debug_implementations,
missing_docs,
// // missing_doc_code_examples, // maybe someday
noop_method_call,
pointer_structural_match,
single_use_lifetimes, // annoying hits on invisible derived impls
trivial_casts,
trivial_numeric_casts,
unreachable_pub,
unused_extern_crates,
unused_import_braces,
unused_lifetimes,
unused_qualifications,
unused_results,
variant_size_differences,
)]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![allow(
clippy::implicit_return,
clippy::blanket_clippy_restriction_lints,
clippy::default_numeric_fallback,
clippy::separated_literal_suffix,
clippy::single_char_lifetime_names,
clippy::missing_docs_in_private_items,
clippy::pattern_type_mismatch,
clippy::shadow_reuse
)]
#![cfg_attr(
all(feature = "anticipate", not(rust_lib_feature = "step_trait")),
feature(step_trait)
)]
#![cfg_attr(
all(feature = "anticipate", not(rust_lib_feature = "unwrap_infallible")),
feature(unwrap_infallible)
)]
#![cfg_attr(
all(feature = "anticipate", not(rust_lang_feature = "never_type")),
feature(never_type)
)]
#[cfg(feature = "std")]
pub mod robust;
pub mod cycle_safe;
#[cfg(feature = "alloc")]
pub mod deep_safe;
#[cfg(feature = "alloc")]
pub mod wide_safe;
pub mod basic;
pub mod generic;
pub mod utils;
cfg_if::cfg_if! {
if #[cfg(feature = "anticipate")] {
mod anticipated;
use anticipated as anticipated_or_like;
use core::iter::Step;
}
else {
mod like_anticipated;
use like_anticipated as anticipated_or_like;
pub use like_anticipated::Step;
}
}
use core::{
cmp::Ordering,
hash::Hash,
};
pub trait Node: Sized
{
type Cmp: Cmp;
type Id: Eq + Hash + Clone;
type Index: Step + Default + Ord;
fn id(&self) -> Self::Id;
#[must_use]
fn get_edge(
&self,
index: &Self::Index,
) -> Option<Self>;
fn equiv_modulo_edges(
&self,
other: &Self,
) -> Self::Cmp;
}
pub trait Cmp
{
fn new_equiv() -> Self;
fn is_equiv(&self) -> bool;
fn from_ord(ord: Ordering) -> Self;
}
impl Cmp for bool
{
#[inline]
fn new_equiv() -> Self
{
true
}
#[inline]
fn is_equiv(&self) -> bool
{
*self
}
#[inline]
fn from_ord(ord: Ordering) -> Self
{
ord.is_eq()
}
}
impl Cmp for Ordering
{
#[inline]
fn new_equiv() -> Self
{
Ordering::Equal
}
#[inline]
fn is_equiv(&self) -> bool
{
self.is_eq()
}
#[inline]
fn from_ord(ord: Ordering) -> Self
{
ord
}
}