diff --git a/src/encoder.rs b/src/encoder.rs index e1318b7..347610c 100644 --- a/src/encoder.rs +++ b/src/encoder.rs @@ -85,7 +85,7 @@ impl SdObjectEncoder { .get_mut(&mut self.object) .map_err(|_| Error::InvalidPath(path.to_string()))? .as_object_mut() - .ok_or(Error::InvalidPath(path.to_string()))?; + .ok_or_else(|| Error::InvalidPath(path.to_string()))?; // Remove the value from the parent and create a disclosure for it. let disclosure = Disclosure::new( @@ -93,7 +93,7 @@ impl SdObjectEncoder { Some(element_key.to_owned()), parent .remove(&element_key) - .ok_or(Error::InvalidPath(path.to_string()))?, + .ok_or_else(|| Error::InvalidPath(path.to_string()))?, ); // Hash the disclosure.