Commit 417c7005 authored by Ben Boeckel's avatar Ben Boeckel
Browse files

clippy: resolve mismatched enum variant size warnings

parent 648f2c38
......@@ -24,7 +24,7 @@ pub enum GitlabHook {
/// A system hook.
System(SystemHook),
/// A web hook from a specific project.
Web(WebHook),
Web(Box<WebHook>),
}
impl<'de> Deserialize<'de> for GitlabHook {
......@@ -37,7 +37,7 @@ impl<'de> Deserialize<'de> for GitlabHook {
// Look for `object_kind` first because some web hooks also have `event_name` which would
// cause a false match here.
let hook_res = if val.pointer("/object_kind").is_some() {
serde_json::from_value(val).map(GitlabHook::Web)
serde_json::from_value(val).map(|hook| GitlabHook::Web(Box::new(hook)))
} else if val.pointer("/event_name").is_some() {
serde_json::from_value(val).map(GitlabHook::System)
} else {
......
......@@ -369,7 +369,7 @@ pub enum SystemHook {
/// A group membership hook.
GroupMember(GroupMemberSystemHook),
/// A push hook.
Push(PushSystemHook),
Push(Box<PushSystemHook>),
}
impl<'de> Deserialize<'de> for SystemHook {
......@@ -412,7 +412,9 @@ impl<'de> Deserialize<'de> for SystemHook {
serde_json::from_value(val).map(SystemHook::GroupMember)
},
"push" | "tag_push" => serde_json::from_value(val).map(SystemHook::Push),
"push" | "tag_push" => {
serde_json::from_value(val).map(|hook| SystemHook::Push(Box::new(hook)))
},
_ => {
return Err(D::Error::custom(format!(
......
......@@ -1523,7 +1523,7 @@ pub struct ExternalIssue {
#[derive(Debug, Clone)]
pub enum IssueReference {
/// A reference to an issue on the same Gitlab host.
Internal(Issue),
Internal(Box<Issue>),
/// An external issue reference.
External(ExternalIssue),
}
......@@ -1545,7 +1545,7 @@ impl<'de> Deserialize<'de> for IssueReference {
let val = <Value as Deserialize>::deserialize(deserializer)?;
serde_json::from_value::<Issue>(val.clone())
.map(IssueReference::Internal)
.map(|issue| IssueReference::Internal(Box::new(issue)))
.or_else(|_| serde_json::from_value::<ExternalIssue>(val).map(IssueReference::External))
.map_err(|err| D::Error::custom(format!("invalid issue reference: {:?}", err)))
}
......
......@@ -720,17 +720,17 @@ pub struct WikiPageHook {
#[derive(Debug, Clone)]
pub enum WebHook {
/// A push hook.
Push(PushHook),
Push(Box<PushHook>),
/// An issue hook.
Issue(IssueHook),
Issue(Box<IssueHook>),
/// A merge request hook.
MergeRequest(MergeRequestHook),
MergeRequest(Box<MergeRequestHook>),
/// A note hook.
Note(NoteHook),
Note(Box<NoteHook>),
/// A build hook.
Build(BuildHook),
Build(Box<BuildHook>),
/// A wiki page hook.
WikiPage(WikiPageHook),
WikiPage(Box<WikiPageHook>),
}
impl<'de> Deserialize<'de> for WebHook {
......@@ -755,15 +755,19 @@ impl<'de> Deserialize<'de> for WebHook {
};
let hook_res = match object_kind.as_ref() {
"push" | "tag_push" => serde_json::from_value(val).map(WebHook::Push),
"push" | "tag_push" => {
serde_json::from_value(val).map(|hook| WebHook::Push(Box::new(hook)))
},
"issue" => serde_json::from_value(val).map(WebHook::Issue),
"issue" => serde_json::from_value(val).map(|hook| WebHook::Issue(Box::new(hook))),
"merge_request" => serde_json::from_value(val).map(WebHook::MergeRequest),
"merge_request" => {
serde_json::from_value(val).map(|hook| WebHook::MergeRequest(Box::new(hook)))
},
"note" => serde_json::from_value(val).map(WebHook::Note),
"note" => serde_json::from_value(val).map(|hook| WebHook::Note(Box::new(hook))),
"build" => serde_json::from_value(val).map(WebHook::Build),
"build" => serde_json::from_value(val).map(|hook| WebHook::Build(Box::new(hook))),
_ => {
return Err(D::Error::invalid_value(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment