-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: deserialization of null storage keys in AccessListItem (#955)
* fix: deserialization of null storage keys in AccessListItem * test: add test * misc: apply review suggestions * Update crates/eips/src/eip2930.rs Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de> * misc: apply review suggestion --------- Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
- Loading branch information
Showing
3 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//! Serde functions for encoding optional values. | ||
use serde::{Deserialize, Deserializer}; | ||
|
||
/// For use with serde's `deserialize_with` on a sequence that must be | ||
/// deserialized as a single but optional (i.e. possibly `null`) value. | ||
pub fn null_as_default<'de, T, D>(deserializer: D) -> Result<T, D::Error> | ||
where | ||
T: Deserialize<'de> + Default, | ||
D: Deserializer<'de>, | ||
{ | ||
let s: Option<T> = Deserialize::deserialize(deserializer)?; | ||
Ok(s.unwrap_or_default()) | ||
} |