File tree 2 files changed +3
-7
lines changed
2 files changed +3
-7
lines changed Original file line number Diff line number Diff line change @@ -129,10 +129,8 @@ impl AccountV1 {
129
129
}
130
130
}
131
131
132
- type ProductFilter = dyn FnMut ( & Product ) -> bool ;
133
-
134
132
impl Contract {
135
- pub ( crate ) fn update_account_cache ( & mut self , account_id : & AccountId , filter : Option < Box < ProductFilter > > ) {
133
+ pub ( crate ) fn update_account_cache ( & mut self , account_id : & AccountId , filter : Option < fn ( & Product ) -> bool > ) {
136
134
let now = env:: block_timestamp_ms ( ) ;
137
135
let products = self . get_products ( account_id, filter) ;
138
136
let account = self . get_account_mut ( account_id) ;
@@ -148,7 +146,7 @@ impl Contract {
148
146
account. update_jar_cache ( product, env:: block_timestamp_ms ( ) ) ;
149
147
}
150
148
151
- fn get_products ( & self , account_id : & AccountId , filter : Option < Box < ProductFilter > > ) -> Vec < Product > {
149
+ fn get_products ( & self , account_id : & AccountId , filter : Option < impl Fn ( & Product ) -> bool > ) -> Vec < Product > {
152
150
let products = self
153
151
. get_account ( account_id)
154
152
. jars
Original file line number Diff line number Diff line change @@ -25,9 +25,7 @@ impl ScoreApi for Contract {
25
25
for ( account_id, new_score) in batch {
26
26
self . update_account_cache (
27
27
& account_id,
28
- Some ( Box :: new ( |product : & Product | {
29
- matches ! ( product. terms, Terms :: ScoreBased ( _) )
30
- } ) ) ,
28
+ Some ( |product : & Product | matches ! ( product. terms, Terms :: ScoreBased ( _) ) ) ,
31
29
) ;
32
30
33
31
let account = self . get_account_mut ( & account_id) ;
You can’t perform that action at this time.
0 commit comments