You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The caveats mention that one should not use copy since it can easily blow up the stack size. What's the recommended method for passing bytes from one stream into another?
The text was updated successfully, but these errors were encountered:
fncopy<R:Read,W:Write>(from:&mutR,to:&mutW) -> io::Result<u64>{use std::io::ErrorKind;// use buf from heap instead of stackletmut buf = Vec::with_capacity(8192);letmut written = 0;loop{let len = match from.read(&mut buf){Ok(0) => returnOk(written),Ok(len) => len,Err(ref e)if e.kind() == ErrorKind::Interrupted => continue,Err(e) => returnErr(e),};
to.write_all(&buf[..len])?;
written += len asu64;}}
The caveats mention that one should not use
copy
since it can easily blow up the stack size. What's the recommended method for passing bytes from one stream into another?The text was updated successfully, but these errors were encountered: