-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compatibility fix for dashboard settings.
- Loading branch information
1 parent
f2bdffa
commit 62403b5
Showing
4 changed files
with
20 additions
and
16 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
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,15 @@ | ||
use serde::{Deserialize, Deserializer}; | ||
|
||
pub fn fail_as_none<'de, T, D>(deserializer: D) -> Result<Option<T>, D::Error> | ||
where | ||
T: Deserialize<'de>, | ||
D: Deserializer<'de>, | ||
{ | ||
// We must fully consume valid json otherwise the error leaves the | ||
// deserializer in an invalid state and it'll still fail | ||
// | ||
// This assumes we always use a json format | ||
let intermediate = serde_json::Value::deserialize(deserializer)?; | ||
|
||
Ok(Option::<T>::deserialize(intermediate).unwrap_or_default()) | ||
} |