From e7d17633694ad663042fea5d3cf4854f8c687c49 Mon Sep 17 00:00:00 2001 From: Michael Sippel Date: Thu, 17 Jun 2021 02:36:37 +0200 Subject: [PATCH] workaround for vec2seq len issue --- nested/src/vec/buffer.rs | 13 +++++++++---- nested/src/vec/vec2seq.rs | 5 +++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/nested/src/vec/buffer.rs b/nested/src/vec/buffer.rs index 5116550..524fa9c 100644 --- a/nested/src/vec/buffer.rs +++ b/nested/src/vec/buffer.rs @@ -34,13 +34,18 @@ where T: Clone + Send + Sync + 'static data: Vec, port: InnerViewPort>> ) -> Self { - let data = Arc::new(RwLock::new(data)); - port.set_view(Some(data.clone())); - VecBuffer { data, cast: port.get_broadcast() } + let mut b = VecBuffer::new(port); + for x in data.into_iter() { + b.push(x); + } + + b } pub fn new(port: InnerViewPort>>) -> Self { - VecBuffer::with_data(Vec::new(), port) + let data = Arc::new(RwLock::new(Vec::new())); + port.set_view(Some(data.clone())); + VecBuffer { data, cast: port.get_broadcast() } } pub fn apply_diff(&mut self, diff: VecDiff) { diff --git a/nested/src/vec/vec2seq.rs b/nested/src/vec/vec2seq.rs index 0c8871e..0fa7372 100644 --- a/nested/src/vec/vec2seq.rs +++ b/nested/src/vec/vec2seq.rs @@ -43,13 +43,14 @@ where T: Clone + Send + Sync + 'static { fn reset(&mut self, view: Option>>>) { let old_len = self.cur_len; self.data = view; - self.cur_len = + self.cur_len = 0; + /* if let Some(data) = self.data.as_ref() { data.read().unwrap().len() } else { 0 }; - +*/ self.cast.notify_each(0 .. std::cmp::max(old_len, self.cur_len)); }