@@ -84,6 +84,8 @@ pub use runtime::spawn;
8484pub use runtime:: Runtime ;
8585
8686use crate :: runtime:: driver:: op:: Op ;
87+ use std:: error:: Error ;
88+ use std:: fmt:: { Debug , Display } ;
8789use std:: future:: Future ;
8890
8991/// Starts an `io_uring` enabled Tokio runtime.
@@ -237,8 +239,7 @@ impl Builder {
237239///
238240/// This type is used as a return value for asynchronous `io-uring` methods that
239241/// require passing ownership of a buffer to the runtime. When the operation
240- /// completes, the buffer is returned whether or not the operation completed
241- /// successfully.
242+ /// completes, the buffer is returned both in the success tuple and as part of the error
242243///
243244/// # Examples
244245///
@@ -254,8 +255,7 @@ impl Builder {
254255/// // Read some data, the buffer is passed by ownership and
255256/// // submitted to the kernel. When the operation completes,
256257/// // we get the buffer back.
257- /// let (res, buf) = file.read_at(buf, 0).await;
258- /// let n = res?;
258+ /// let (n, buf) = file.read_at(buf, 0).await?;
259259///
260260/// // Display the contents
261261/// println!("{:?}", &buf[..n]);
@@ -271,6 +271,17 @@ pub type BufResult<T, B> = std::result::Result<(T, B), BufError<B>>;
271271#[ derive( Debug ) ]
272272pub struct BufError < B > ( pub std:: io:: Error , pub B ) ;
273273
274+ impl < T > Display for BufError < T > {
275+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
276+ Debug :: fmt ( & self . 0 , f)
277+ }
278+ }
279+
280+ impl < T : Debug > Error for BufError < T > {
281+ fn source ( & self ) -> Option < & ( dyn Error + ' static ) > {
282+ Some ( & self . 0 )
283+ }
284+ }
274285
275286impl < B > BufError < B > {
276287 /// Applies a function to the contained buffer, returning a new `BufError`.
0 commit comments