File tree Expand file tree Collapse file tree 2 files changed +14
-16
lines changed
cedar-policy-generators/src Expand file tree Collapse file tree 2 files changed +14
-16
lines changed Original file line number Diff line number Diff line change @@ -102,7 +102,8 @@ pub fn dump(
102
102
resource : dump_request_var ( q. resource ( ) ) ,
103
103
context : dump_context (
104
104
q. context ( )
105
- . expect ( "`dump` does not support requests missing context" ) ,
105
+ . expect ( "`dump` does not support requests missing context" )
106
+ . clone ( ) ,
106
107
) ,
107
108
enable_request_validation : true ,
108
109
decision : a. decision ,
@@ -230,22 +231,19 @@ fn dump_request_var(var: &EntityUIDEntry) -> Option<JsonValueWithNoDuplicateKeys
230
231
}
231
232
232
233
/// Dump the context to a "natural" json value
233
- fn dump_context ( context : & Context ) -> JsonValueWithNoDuplicateKeys {
234
+ fn dump_context ( context : Context ) -> JsonValueWithNoDuplicateKeys {
234
235
let context = context
235
- . iter ( )
236
- . map ( |it| {
237
- it. map ( |( k, pval) | {
238
- (
239
- k. clone ( ) ,
240
- RestrictedExpr :: try_from ( pval)
241
- . unwrap ( )
242
- . to_natural_json ( )
243
- . unwrap ( ) ,
244
- )
245
- } )
246
- . collect :: < HashMap < _ , _ > > ( )
236
+ . into_iter ( )
237
+ . map ( |( k, pval) | {
238
+ (
239
+ k,
240
+ RestrictedExpr :: try_from ( pval)
241
+ . unwrap ( )
242
+ . to_natural_json ( )
243
+ . unwrap ( ) ,
244
+ )
247
245
} )
248
- . unwrap_or_default ( ) ;
246
+ . collect :: < HashMap < _ , _ > > ( ) ;
249
247
serde_json:: to_value ( context)
250
248
. expect ( "failed to serialize context" )
251
249
. into ( )
Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ impl std::fmt::Display for Request {
58
58
"(principal : {}, action: {}, resource: {})" ,
59
59
self . principal, self . action, self . resource
60
60
) ?;
61
- let mut context = self . context . iter ( ) . unwrap ( ) . peekable ( ) ;
61
+ let mut context = self . context . clone ( ) . into_iter ( ) . peekable ( ) ;
62
62
if context. peek ( ) . is_some ( ) {
63
63
writeln ! ( f, "\n With context: {{" ) ?;
64
64
for ( attr, val) in context {
You can’t perform that action at this time.
0 commit comments