From ad2c79cbe708399ad80fca19b9b4442297aa3698 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Sch=C3=A4fer?= Date: Sat, 10 Aug 2024 09:34:05 +0200 Subject: [PATCH] xso: document some specific trait implementations --- xso/src/asxml.rs | 3 +++ xso/src/fromxml.rs | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/xso/src/asxml.rs b/xso/src/asxml.rs index 3d15bd91..3b4e449e 100644 --- a/xso/src/asxml.rs +++ b/xso/src/asxml.rs @@ -38,6 +38,8 @@ impl<'x, T: Iterator, Error>>> Iterator for OptionAsXml AsXml for Option { type ItemIter<'x> = OptionAsXml> where T: 'x; @@ -60,6 +62,7 @@ impl<'x, T: Iterator, Error>>> Iterator for BoxAsXml { } } +/// Emits the contents of `T` unchanged. impl AsXml for Box { type ItemIter<'x> = BoxAsXml> where T: 'x; diff --git a/xso/src/fromxml.rs b/xso/src/fromxml.rs index 3c07f627..56d86c8f 100644 --- a/xso/src/fromxml.rs +++ b/xso/src/fromxml.rs @@ -26,6 +26,12 @@ impl FromEventsBuilder for OptionBuilder { } } +/// Parsers `T` into `Some(.)`. +/// +/// Note that this never generates `None`: The main use case is to allow +/// external (i.e. without calling `from_events`) defaulting to `None` and +/// for optional serialisation (the [`AsXml`][`crate::AsXml`] implementation +/// on `Option` emits nothing for `None`). impl FromXml for Option { type Builder = OptionBuilder; @@ -48,6 +54,7 @@ impl FromEventsBuilder for BoxBuilder { } } +/// Parsers `T` into a `Box`. impl FromXml for Box { type Builder = BoxBuilder;