From 6867297eea28aeb53df0aef1b28ce61bcba52982 Mon Sep 17 00:00:00 2001 From: Michael Sippel Date: Sat, 7 Jan 2023 13:13:27 +0100 Subject: [PATCH] singleton2sequence: value only at first element fixes chain with singleton tosequence filter --- nested/src/list/editor.rs | 12 +----------- nested/src/singleton/to_sequence.rs | 8 ++++++-- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/nested/src/list/editor.rs b/nested/src/list/editor.rs index f4b225e..b9b3ae6 100644 --- a/nested/src/list/editor.rs +++ b/nested/src/list/editor.rs @@ -66,18 +66,8 @@ impl ListEditor { addr_port: VecBuffer::>>::with_data( vec![ cursor.get_port() - .map( - |x| { - // todo implement this with filter_map - let mut b = VecBuffer::new(); - if let Some(i) = x.idx { - b.push(i); - } - b.get_port().to_sequence() - } - ) .to_sequence() - .flatten(), + .filter_map(|cur| cur.idx), cursor.get_port() .map({ let data = data.clone(); diff --git a/nested/src/singleton/to_sequence.rs b/nested/src/singleton/to_sequence.rs index 21579b9..73f88ab 100644 --- a/nested/src/singleton/to_sequence.rs +++ b/nested/src/singleton/to_sequence.rs @@ -51,8 +51,12 @@ where { type Item = SrcView::Item; - fn get(&self, _idx: &usize) -> Option { - Some(self.src_view.as_ref()?.get()) + fn get(&self, idx: &usize) -> Option { + if *idx == 0 { + Some(self.src_view.as_ref()?.get()) + } else { + None + } } fn len(&self) -> Option {