diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/generated/structs.rs | 1 | ||||
-rw-r--r-- | src/lib.rs | 12 |
2 files changed, 13 insertions, 0 deletions
diff --git a/src/generated/structs.rs b/src/generated/structs.rs index f7b8ce8..5b97ac9 100644 --- a/src/generated/structs.rs +++ b/src/generated/structs.rs @@ -2034,6 +2034,7 @@ pub struct PullRequest { #[serde(deserialize_with = "crate::none_if_blank_url")] pub patch_url: Option<url::Url>, pub pin_order: Option<u64>, + #[serde(deserialize_with = "crate::requested_reviewers_ignore_null")] pub requested_reviewers: Option<Vec<User>>, pub state: Option<StateType>, pub title: Option<String>, @@ -358,6 +358,18 @@ where .or(Ok(None)) } +fn requested_reviewers_ignore_null<'de, D, DE>( + deserializer: D, +) -> Result<Option<Vec<structs::User>>, DE> +where + D: Deserializer<'de>, + DE: serde::de::Error, +{ + let list: Option<Vec<Option<structs::User>>> = + Option::deserialize(deserializer).map_err(DE::custom)?; + Ok(list.map(|list| list.into_iter().filter_map(|x| x).collect::<Vec<_>>())) +} + fn parse_ssh_url(raw_url: &String) -> Result<Url, url::ParseError> { // in case of a non-standard ssh-port (not 22), the ssh url coming from the forgejo API // is actually parseable by the url crate, so try to do that first |