/// An iterator that produces *n* repetitions of an element. /// /// See [`repeat_n()`](crate::repeat_n) for more information. #[must_use = "iterators are lazy and do nothing unless consumed"] #[derive(Clone, Debug)] pubstruct RepeatN<A> { pub(crate) elt: Option<A>,
n: usize,
}
/// Create an iterator that produces `n` repetitions of `element`. pubfn repeat_n<A>(element: A, n: usize) -> RepeatN<A> where
A: Clone,
{ if n == 0 {
RepeatN { elt: None, n }
} else {
RepeatN {
elt: Some(element),
n,
}
}
}
impl<A> Iterator for RepeatN<A> where
A: Clone,
{ type Item = A;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.