singleton2sequence: value only at first element

fixes chain with singleton tosequence filter
This commit is contained in:
Michael Sippel 2023-01-07 13:13:27 +01:00
parent 47b8900adc
commit 6867297eea
Signed by: senvas
GPG key ID: F96CF119C34B64A6
2 changed files with 7 additions and 13 deletions

View file

@ -66,18 +66,8 @@ impl ListEditor {
addr_port: VecBuffer::<OuterViewPort<dyn SequenceView<Item = isize>>>::with_data( addr_port: VecBuffer::<OuterViewPort<dyn SequenceView<Item = isize>>>::with_data(
vec![ vec![
cursor.get_port() 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() .to_sequence()
.flatten(), .filter_map(|cur| cur.idx),
cursor.get_port() cursor.get_port()
.map({ .map({
let data = data.clone(); let data = data.clone();

View file

@ -51,8 +51,12 @@ where
{ {
type Item = SrcView::Item; type Item = SrcView::Item;
fn get(&self, _idx: &usize) -> Option<Self::Item> { fn get(&self, idx: &usize) -> Option<Self::Item> {
if *idx == 0 {
Some(self.src_view.as_ref()?.get()) Some(self.src_view.as_ref()?.get())
} else {
None
}
} }
fn len(&self) -> Option<usize> { fn len(&self) -> Option<usize> {