replace usages of algo::generate with iter::successors from std

This commit is contained in:
Robin Freyler
2019-04-13 16:43:49 +02:00
parent 8887782c4a
commit 6aae0cf7fa
6 changed files with 17 additions and 24 deletions

View File

@@ -46,13 +46,3 @@ pub fn non_trivia_sibling(element: SyntaxElement, direction: Direction) -> Optio
pub fn find_covering_element(root: &SyntaxNode, range: TextRange) -> SyntaxElement {
root.0.covering_node(range).into()
}
// Replace with `std::iter::successors` in `1.34.0`
pub fn generate<T>(seed: Option<T>, step: impl Fn(&T) -> Option<T>) -> impl Iterator<Item = T> {
::itertools::unfold(seed, move |slot| {
slot.take().map(|curr| {
*slot = step(&curr);
curr
})
})
}