@@ -2,6 +2,7 @@ mod coefficient;
2
2
mod core;
3
3
pub mod representation;
4
4
5
+ use bincode:: { de:: read:: Reader , enc:: write:: Writer , Decode , Encode } ;
5
6
use representation:: InlineVar ;
6
7
use smartstring:: { LazyCompact , SmartString } ;
7
8
@@ -22,6 +23,7 @@ pub use self::representation::{
22
23
} ;
23
24
use self :: representation:: { FunView , RawAtom } ;
24
25
26
+
25
27
/// A function that is called after normalization of the arguments.
26
28
/// If the input, the first argument, is normalized, the function should return `false`.
27
29
/// Otherwise, the function must return `true` and set the second argument to the normalized value.
@@ -35,6 +37,7 @@ pub enum FunctionAttribute {
35
37
Linear ,
36
38
}
37
39
40
+ use std:: result;
38
41
/// A symbol, for example the name of a variable or the name of a function,
39
42
/// together with its properties.
40
43
#[ derive( Copy , Clone , Hash , PartialEq , Eq , PartialOrd , Ord ) ]
@@ -47,6 +50,49 @@ pub struct Symbol {
47
50
is_linear : bool ,
48
51
}
49
52
53
+ impl < __Context > :: bincode:: Decode < __Context > for Symbol {
54
+ fn decode < __D : :: bincode:: de:: Decoder < Context = __Context > > (
55
+ decoder : & mut __D ,
56
+ ) -> Result < Self , :: bincode:: error:: DecodeError > {
57
+ Ok ( Self {
58
+ id : :: bincode:: Decode :: decode ( decoder) ?,
59
+ wildcard_level : :: bincode:: Decode :: decode ( decoder) ?,
60
+ is_symmetric : :: bincode:: Decode :: decode ( decoder) ?,
61
+ is_antisymmetric : :: bincode:: Decode :: decode ( decoder) ?,
62
+ is_cyclesymmetric : :: bincode:: Decode :: decode ( decoder) ?,
63
+ is_linear : :: bincode:: Decode :: decode ( decoder) ?,
64
+ } )
65
+ }
66
+ }
67
+ impl < ' __de , __Context > :: bincode:: BorrowDecode < ' __de , __Context > for Symbol {
68
+ fn borrow_decode < __D : :: bincode:: de:: BorrowDecoder < ' __de , Context = __Context > > (
69
+ decoder : & mut __D ,
70
+ ) -> Result < Self , :: bincode:: error:: DecodeError > {
71
+ Ok ( Self {
72
+ id : :: bincode:: BorrowDecode :: < ' _ , __Context > :: borrow_decode ( decoder) ?,
73
+ wildcard_level : :: bincode:: BorrowDecode :: < ' _ , __Context > :: borrow_decode ( decoder) ?,
74
+ is_symmetric : :: bincode:: BorrowDecode :: < ' _ , __Context > :: borrow_decode ( decoder) ?,
75
+ is_antisymmetric : :: bincode:: BorrowDecode :: < ' _ , __Context > :: borrow_decode ( decoder) ?,
76
+ is_cyclesymmetric : :: bincode:: BorrowDecode :: < ' _ , __Context > :: borrow_decode ( decoder) ?,
77
+ is_linear : :: bincode:: BorrowDecode :: < ' _ , __Context > :: borrow_decode ( decoder) ?,
78
+ } )
79
+ }
80
+ }
81
+
82
+ impl :: bincode:: Encode for Symbol {
83
+ fn encode < __E : :: bincode:: enc:: Encoder > (
84
+ & self ,
85
+ encoder : & mut __E ,
86
+ ) -> Result < ( ) , :: bincode:: error:: EncodeError > {
87
+ :: bincode:: Encode :: encode ( & self . id , encoder) ?;
88
+ :: bincode:: Encode :: encode ( & self . wildcard_level , encoder) ?;
89
+ :: bincode:: Encode :: encode ( & self . is_symmetric , encoder) ?;
90
+ :: bincode:: Encode :: encode ( & self . is_antisymmetric , encoder) ?;
91
+ :: bincode:: Encode :: encode ( & self . is_cyclesymmetric , encoder) ?;
92
+ :: bincode:: Encode :: encode ( & self . is_linear , encoder) ?;
93
+ Ok ( ( ) )
94
+ }
95
+ }
50
96
impl std:: fmt:: Debug for Symbol {
51
97
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
52
98
f. write_fmt ( format_args ! ( "{}" , self . id) ) ?;
0 commit comments