From 8b0210d23367efecbf6e8ee9f19f372ff7d4fad3 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 4 Sep 2018 19:00:01 +0300 Subject: simplify --- crates/libsyntax2/src/yellow/red.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'crates') diff --git a/crates/libsyntax2/src/yellow/red.rs b/crates/libsyntax2/src/yellow/red.rs index 1ee6bdf18..84cfe4fba 100644 --- a/crates/libsyntax2/src/yellow/red.rs +++ b/crates/libsyntax2/src/yellow/red.rs @@ -56,13 +56,13 @@ impl RedNode { } fn new(green: GreenNode, parent: Option) -> RedNode { - let start_offset = parent.as_ref().map(|it| it.start_offset).unwrap_or(0.into()); + let mut start_offset = parent.as_ref().map(|it| it.start_offset).unwrap_or(0.into()); let children = green.children() .iter() - .scan(start_offset, |start_offset, child| { - let res = RedChild::Zigot(*start_offset); - *start_offset += child.text_len(); - Some(res) + .map(|child| { + let off = start_offset; + start_offset += child.text_len(); + RedChild::Zigot(off) }) .collect::>() .into_boxed_slice(); -- cgit v1.2.3