#![deny(
rust_2018_compatibility,
rust_2018_idioms,
nonstandard_style,
unused,
future_incompatible,
non_camel_case_types,
unused_parens,
non_upper_case_globals,
unused_qualifications,
unused_results,
unused_imports,
unused_variables,
bare_trait_objects,
ellipsis_inclusive_range_patterns,
elided_lifetimes_in_paths
)]
#[derive(thiserror::Error, Debug)]
pub enum CppMapError {
#[error("error: Some error with the index map")]
InvalidIndex,
#[error("error: Some error with the index map")]
IndexError(String),
#[error("error: a key was missing rank")]
MissingRank,
#[error("error: rank collision")]
KeyError(String),
}
pub trait IsLessThan {
fn is_less_than(&self, other: &Self) -> bool;
}
macro_rules! impl_is_less_than {
($($t:ty),*) => {
$(
impl IsLessThan for $t {
fn is_less_than(&self, other: &Self) -> bool {
self < other
}
}
)*
};
}
impl_is_less_than!(i8, i16, i32, i64, i128, isize);
impl_is_less_than!(u8, u16, u32, u64, u128, usize);
impl_is_less_than!(f32, f64);
impl_is_less_than!(char);
impl_is_less_than!(&str);
impl_is_less_than!(String);
#[doc(hidden)]
#[cfg(any(test, debug_assertions))]
#[macro_export]
macro_rules! dbg_assert {
($($arg:tt)*) => {
assert!($($arg)*);
};
}
#[cfg(not(any(test, debug_assertions)))]
#[macro_export]
macro_rules! dbg_assert {
($($arg:tt)*) => {};
}
pub trait IsEqual {
fn is_equal(&self, other: &Self) -> bool;
}
impl<T: IsLessThan> IsEqual for T {
#[inline(always)]
fn is_equal(&self, other: &Self) -> bool {
!self.is_less_than(other) && !other.is_less_than(self)
}
}
pub mod linkedlist;
pub mod skiplist;
pub mod prelude {
pub use crate::CppMapError;
pub use crate::IsLessThan;
pub use crate::linkedlist::LinkedList;
pub use crate::skiplist::SkipList;
}