From b2886d9c9e567e10362a68e5bf42d1cd8267d5ca Mon Sep 17 00:00:00 2001 From: Cyborus Date: Mon, 1 Jul 2024 13:03:00 -0400 Subject: fix: only wrap return values in `Option` once --- generator/src/methods.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/generator/src/methods.rs b/generator/src/methods.rs index 8039f96..93d5f57 100644 --- a/generator/src/methods.rs +++ b/generator/src/methods.rs @@ -555,14 +555,18 @@ impl ResponseType { fn merge(self, other: Self) -> eyre::Result { let headers = match (self.headers, other.headers) { (Some(a), Some(b)) if a != b => eyre::bail!("incompatible header types in response"), - (Some(a), None) => Some(format!("Option<{a}>")), - (None, Some(b)) => Some(format!("Option<{b}>")), + (Some(a), None) if !a.starts_with("Option<") => Some(format!("Option<{a}>")), + (None, Some(b)) if !b.starts_with("Option<") => Some(format!("Option<{b}>")), (a, b) => a.or(b), }; let body = match (self.body.as_deref(), other.body.as_deref()) { (Some(a), Some(b)) if a != b => eyre::bail!("incompatible header types in response"), - (Some(a), Some("()") | None) => Some(format!("Option<{a}>")), - (Some("()") | None, Some(b)) => Some(format!("Option<{b}>")), + (Some(a), Some("()") | None) if !a.starts_with("Option<") => { + Some(format!("Option<{a}>")) + } + (Some("()") | None, Some(b)) if !b.starts_with("Option<") => { + Some(format!("Option<{b}>")) + } (_, _) => self.body.or(other.body), }; use ResponseKind::*; -- cgit v1.2.3