diff --git a/cedar-drt/fuzz/src/dump.rs b/cedar-drt/fuzz/src/dump.rs index f9f80b078..f0b1cb73d 100644 --- a/cedar-drt/fuzz/src/dump.rs +++ b/cedar-drt/fuzz/src/dump.rs @@ -102,7 +102,8 @@ pub fn dump( resource: dump_request_var(q.resource()), context: dump_context( q.context() - .expect("`dump` does not support requests missing context"), + .expect("`dump` does not support requests missing context") + .clone(), ), enable_request_validation: true, decision: a.decision, @@ -230,22 +231,19 @@ fn dump_request_var(var: &EntityUIDEntry) -> Option JsonValueWithNoDuplicateKeys { +fn dump_context(context: Context) -> JsonValueWithNoDuplicateKeys { let context = context - .iter() - .map(|it| { - it.map(|(k, pval)| { - ( - k.clone(), - RestrictedExpr::try_from(pval) - .unwrap() - .to_natural_json() - .unwrap(), - ) - }) - .collect::>() + .into_iter() + .map(|(k, pval)| { + ( + k, + RestrictedExpr::try_from(pval) + .unwrap() + .to_natural_json() + .unwrap(), + ) }) - .unwrap_or_default(); + .collect::>(); serde_json::to_value(context) .expect("failed to serialize context") .into() diff --git a/cedar-policy-generators/src/request.rs b/cedar-policy-generators/src/request.rs index 5f1df3334..540679755 100644 --- a/cedar-policy-generators/src/request.rs +++ b/cedar-policy-generators/src/request.rs @@ -58,7 +58,7 @@ impl std::fmt::Display for Request { "(principal : {}, action: {}, resource: {})", self.principal, self.action, self.resource )?; - let mut context = self.context.iter().unwrap().peekable(); + let mut context = self.context.clone().into_iter().peekable(); if context.peek().is_some() { writeln!(f, "\nWith context: {{")?; for (attr, val) in context {