File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change
1
+ use crate :: value:: { Value , ToValue } ;
2
+ use std:: rc:: Rc ;
3
+ use crate :: persistent_list_map;
4
+ use crate :: protocol:: ProtocolCastable ;
5
+
6
+ define_protocol ! ( IPersistentMap , PersistentListMap ) ;
7
+
8
+ impl persistent_list_map:: IPersistentMap for IPersistentMap {
9
+ fn get ( & self , key : & Rc < Value > ) -> Rc < Value > {
10
+ match & * self . value {
11
+ Value :: PersistentListMap ( plist_map) => {
12
+ plist_map. get ( key)
13
+ } ,
14
+ _ => panic ! ( "Called Iterable iter on non-iterable" ) ,
15
+ }
16
+ }
17
+ fn assoc ( & self , key : Rc < Value > , value : Rc < Value > ) -> IPersistentMap {
18
+ match & * self . value {
19
+ Value :: PersistentListMap ( plist_map) => {
20
+ plist_map. assoc ( key, value) . to_rc_value ( ) . as_protocol :: < IPersistentMap > ( )
21
+ } ,
22
+ _ => panic ! ( "Called Iterable iter on non-iterable" ) ,
23
+ }
24
+ }
25
+ }
You can’t perform that action at this time.
0 commit comments