From 9a3bbb599feae9766f15f2dcf1e5b05701ba0a77 Mon Sep 17 00:00:00 2001 From: Fangdun Tsai Date: Sun, 29 Dec 2024 16:48:40 +0800 Subject: [PATCH] fix(core): no need to use map --- viz-core/src/response.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/viz-core/src/response.rs b/viz-core/src/response.rs index 6560c91..b7ef1d1 100644 --- a/viz-core/src/response.rs +++ b/viz-core/src/response.rs @@ -71,14 +71,12 @@ pub trait ResponseExt: private::Sealed + Sized { use bytes::{BufMut, BytesMut}; let mut buf = BytesMut::with_capacity(128).writer(); - serde_json::to_writer(&mut buf, &body) - .map(|()| { - Response::with( - Full::new(buf.into_inner().freeze()), - mime::APPLICATION_JSON.as_ref(), - ) - }) - .map_err(crate::types::PayloadError::Json) + serde_json::to_writer(&mut buf, &body).map_err(crate::types::PayloadError::Json)?; + + Ok(Response::with( + Full::new(buf.into_inner().freeze()), + mime::APPLICATION_JSON.as_ref(), + )) } /// Responds to a stream.