Skip to main content

yui_core/abst/
basic.rs

1//! The two shape traits every math object satisfies: [`MathType`], which names
2//! the object via `math_symbol()`, and [`IndexType`], its hashable/ordered form
3//! used for keys and grading indices.
4
5use std::fmt::{Debug, Display};
6use std::hash::Hash;
7
8/// A type that represents a mathematical object, identified by a symbol
9/// returned from [`math_symbol`](MathType::math_symbol).
10pub trait MathType:
11    Default +
12    PartialEq +
13    Eq +
14    Clone +
15    Send +
16    Sync +
17    Display +
18    Debug +
19    'static
20{
21    fn math_symbol() -> String;
22}
23
24/// A type usable as an index or key — hashable, totally ordered, and carrying
25/// the basic shape bounds. Blanket-implemented for any type satisfying them.
26pub trait IndexType:
27    Default +
28    PartialEq +
29    Eq +
30    Hash +
31    PartialOrd +
32    Ord +
33    Clone +
34    Send +
35    Sync +
36    Display +
37    Debug +
38    'static
39{}
40
41impl<T> IndexType for T where T:
42    Default +
43    PartialEq +
44    Eq +
45    Hash +
46    PartialOrd +
47    Ord +
48    Clone +
49    Send +
50    Sync +
51    Display +
52    Debug +
53    'static
54{}