Skip to content

Commit

Permalink
chore(interop): Flatten nested conditional structure (#2112)
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto authored Jan 1, 2025
1 parent 01f8754 commit 220e958
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions interop/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,11 @@ impl<B: HttpBody + Unpin> HttpBody for MergeTrailers<B> {
) -> Poll<Option<StdResult<http_body::Frame<Self::Data>, Self::Error>>> {
let this = self.get_mut();
let mut frame = ready!(Pin::new(&mut this.inner).poll_frame(cx)?);
if let Some(frame) = frame.as_mut() {
if let Some(trailers) = frame.trailers_mut() {
if let Some((key, value)) = &this.trailer {
trailers.insert(key.clone(), value.clone());
}
}
if let (Some(trailers), Some((key, value))) = (
frame.as_mut().and_then(|frame| frame.trailers_mut()),
&this.trailer,
) {
trailers.insert(key.clone(), value.clone());
}
Poll::Ready(frame.map(Ok))
}
Expand Down

0 comments on commit 220e958

Please sign in to comment.