This is an automated email from the ASF dual-hosted git repository.

xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git


The following commit(s) were added to refs/heads/main by this push:
     new 3bced977b refactor: Relax bounds on Writer::{sink, copy} (#3027)
3bced977b is described below

commit 3bced977b6a6227cd7310228319646af46b4b02c
Author: Huon Wilson <[email protected]>
AuthorDate: Sun Sep 10 14:30:31 2023 +1000

    refactor: Relax bounds on Writer::{sink, copy} (#3027)
---
 core/src/types/writer.rs | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/core/src/types/writer.rs b/core/src/types/writer.rs
index 0474d6ea4..f32672b4b 100644
--- a/core/src/types/writer.rs
+++ b/core/src/types/writer.rs
@@ -132,9 +132,9 @@ impl Writer {
     ///     Ok(())
     /// }
     /// ```
-    pub async fn sink<S, T>(&mut self, mut sink_from: S) -> Result<u64>
+    pub async fn sink<S, T>(&mut self, sink_from: S) -> Result<u64>
     where
-        S: futures::Stream<Item = Result<T>> + Send + Sync + Unpin + 'static,
+        S: futures::Stream<Item = Result<T>>,
         T: Into<Bytes>,
     {
         let w = if let State::Idle(Some(w)) = &mut self.state {
@@ -146,6 +146,7 @@ impl Writer {
             );
         };
 
+        let mut sink_from = Box::pin(sink_from);
         let mut written = 0;
         while let Some(bs) = sink_from.try_next().await? {
             let mut bs = bs.into();
@@ -190,7 +191,7 @@ impl Writer {
     /// ```
     pub async fn copy<R>(&mut self, read_from: R) -> Result<u64>
     where
-        R: futures::AsyncRead + Send + Sync + Unpin + 'static,
+        R: futures::AsyncRead,
     {
         futures::io::copy(read_from, self).await.map_err(|err| {
             Error::new(ErrorKind::Unexpected, "copy into writer failed")

Reply via email to