xso: document some specific trait implementations

This commit is contained in:
Jonas Schäfer 2024-08-10 09:34:05 +02:00
parent 2ff81b3923
commit ad2c79cbe7
2 changed files with 10 additions and 0 deletions

View file

@ -38,6 +38,8 @@ impl<'x, T: Iterator<Item = Result<Item<'x>, Error>>> Iterator for OptionAsXml<T
} }
} }
/// Emits the contents of `Some(.)` unchanged if present and nothing
/// otherwise.
impl<T: AsXml> AsXml for Option<T> { impl<T: AsXml> AsXml for Option<T> {
type ItemIter<'x> = OptionAsXml<T::ItemIter<'x>> where T: 'x; type ItemIter<'x> = OptionAsXml<T::ItemIter<'x>> where T: 'x;
@ -60,6 +62,7 @@ impl<'x, T: Iterator<Item = Result<Item<'x>, Error>>> Iterator for BoxAsXml<T> {
} }
} }
/// Emits the contents of `T` unchanged.
impl<T: AsXml> AsXml for Box<T> { impl<T: AsXml> AsXml for Box<T> {
type ItemIter<'x> = BoxAsXml<T::ItemIter<'x>> where T: 'x; type ItemIter<'x> = BoxAsXml<T::ItemIter<'x>> where T: 'x;

View file

@ -26,6 +26,12 @@ impl<T: FromEventsBuilder> FromEventsBuilder for OptionBuilder<T> {
} }
} }
/// 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<T>` emits nothing for `None`).
impl<T: FromXml> FromXml for Option<T> { impl<T: FromXml> FromXml for Option<T> {
type Builder = OptionBuilder<T::Builder>; type Builder = OptionBuilder<T::Builder>;
@ -48,6 +54,7 @@ impl<T: FromEventsBuilder> FromEventsBuilder for BoxBuilder<T> {
} }
} }
/// Parsers `T` into a `Box`.
impl<T: FromXml> FromXml for Box<T> { impl<T: FromXml> FromXml for Box<T> {
type Builder = BoxBuilder<T::Builder>; type Builder = BoxBuilder<T::Builder>;