xso: implement support for defaulting extracts
This commit is contained in:
parent
f318dd460d
commit
c7c180feb6
7 changed files with 388 additions and 31 deletions
|
|
@ -86,6 +86,17 @@ pub trait AsXml {
|
|||
/// Helper iterator to convert an `Option<T>` to XML.
|
||||
pub struct OptionAsXml<T: Iterator>(Option<T>);
|
||||
|
||||
impl<T: Iterator> OptionAsXml<T> {
|
||||
/// Construct a new iterator, wrapping the given iterator.
|
||||
///
|
||||
/// If `inner` is `None`, this iterator terminates immediately. Otherwise,
|
||||
/// it yields the elements yielded by `inner` until `inner` finishes,
|
||||
/// after which this iterator completes, too.
|
||||
pub fn new(inner: Option<T>) -> Self {
|
||||
Self(inner)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'x, T: Iterator<Item = Result<Item<'x>, self::error::Error>>> Iterator for OptionAsXml<T> {
|
||||
type Item = Result<Item<'x>, self::error::Error>;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue