File tree Expand file tree Collapse file tree 2 files changed +3
-12
lines changed Expand file tree Collapse file tree 2 files changed +3
-12
lines changed Original file line number Diff line number Diff line change @@ -9,4 +9,3 @@ readme = "../README.md"
99edition = " 2021"
1010
1111[dependencies ]
12- either = " 1.13.0"
Original file line number Diff line number Diff line change @@ -13,8 +13,6 @@ use std::cmp::{Ord, Ordering};
1313use std:: error:: Error as StdError ;
1414use std:: io;
1515
16- use either:: Either ;
17-
1816/// A boxed `Send + Sync + 'static` error.
1917pub type BoxedError = Box < dyn StdError + Send + Sync + ' static > ;
2018
@@ -35,20 +33,14 @@ pub trait BytesEncode<'a> {
3533 /// Encode the given item as bytes and write it into the writer. Returns the amount of bytes
3634 /// that were written. This function by default forwards to
3735 /// [`bytes_encode`][BytesEncode::bytes_encode].
38- ///
39- /// # Errors
40- ///
41- /// [`Either`] is used to handle the 2 different errors this function can return.
42- /// [`Either::Left`] is used for errors from [`bytes_encode`][BytesEncode::bytes_encode] and
43- /// [`Either::Right`] is used for errors from the writer (I/O errors).
4436 fn bytes_encode_into_writer < W : io:: Write > (
4537 item : & ' a Self :: EItem ,
4638 writer : & mut W ,
47- ) -> Result < usize , Either < Self :: Error , io :: Error > > {
48- let bytes = Self :: bytes_encode ( item) . map_err ( Either :: Left ) ?;
39+ ) -> Result < usize , BoxedError > {
40+ let bytes = Self :: bytes_encode ( item) ?;
4941 let bytes = bytes. as_ref ( ) ;
5042
51- writer. write_all ( bytes) . map_err ( Either :: Right ) ?;
43+ writer. write_all ( bytes) ?;
5244
5345 Ok ( bytes. len ( ) )
5446 }
You can’t perform that action at this time.
0 commit comments