11use std:: future:: Future ;
2+ use std:: result:: Result as StdResult ;
23
34use tokio:: io:: { AsyncWrite , AsyncWriteExt } ;
45
5- use crate :: errors:: Result ;
6+ use crate :: errors:: { Error , Result } ;
67use crate :: events:: { BytesCData , BytesText , Event } ;
78use crate :: { ElementWriter , Writer } ;
89
@@ -252,6 +253,8 @@ impl<'a, W: AsyncWrite + Unpin> ElementWriter<'a, W> {
252253 /// # use quick_xml::writer::Writer;
253254 /// # use quick_xml::events::BytesText;
254255 /// # use tokio::io::AsyncWriteExt;
256+ /// use quick_xml::Error;
257+ ///
255258 /// # #[tokio::main(flavor = "current_thread")] async fn main() {
256259 /// let mut buffer = Vec::new();
257260 /// let mut tokio_buffer = tokio::io::BufWriter::new(&mut buffer);
@@ -260,7 +263,8 @@ impl<'a, W: AsyncWrite + Unpin> ElementWriter<'a, W> {
260263 /// writer
261264 /// .create_element("outer")
262265 /// .with_attributes([("attr1", "value1"), ("attr2", "value2")])
263- /// .write_inner_content_async(|writer| async move {
266+ /// // We need to provide error type, because it is not named somewhere explicitly
267+ /// .write_inner_content_async::<_, _, Error>(|writer| async move {
264268 /// let fruits = ["apple", "orange", "banana"];
265269 /// for (quant, item) in fruits.iter().enumerate() {
266270 /// writer
@@ -272,12 +276,11 @@ impl<'a, W: AsyncWrite + Unpin> ElementWriter<'a, W> {
272276 /// writer
273277 /// .create_element("inner")
274278 /// .write_inner_content_async(|writer| async move {
275- /// writer.create_element("empty").write_empty_async().await?;
276- /// Ok(writer)
279+ /// writer.create_element("empty").write_empty_async().await
277280 /// })
278281 /// .await?;
279282 ///
280- /// Ok(writer)
283+ /// Ok(writer)
281284 /// })
282285 /// .await
283286 /// .expect("cannot write content");
@@ -295,13 +298,14 @@ impl<'a, W: AsyncWrite + Unpin> ElementWriter<'a, W> {
295298 /// </outer>"#
296299 /// );
297300 /// # }
298- pub async fn write_inner_content_async < F , Fut > (
301+ pub async fn write_inner_content_async < F , Fut , E > (
299302 mut self ,
300303 closure : F ,
301- ) -> Result < & ' a mut Writer < W > >
304+ ) -> StdResult < & ' a mut Writer < W > , E >
302305 where
303306 F : FnOnce ( & ' a mut Writer < W > ) -> Fut ,
304- Fut : Future < Output = Result < & ' a mut Writer < W > > > ,
307+ Fut : Future < Output = StdResult < & ' a mut Writer < W > , E > > ,
308+ E : From < Error > ,
305309 {
306310 self . writer
307311 . write_event_async ( Event :: Start ( self . start_tag . borrow ( ) ) )
0 commit comments