From 0a1b4c2c23eda5782c15abee5bfd0e48d1759c96 Mon Sep 17 00:00:00 2001 From: Michael Sippel Date: Sat, 16 Jan 2021 16:09:16 +0100 Subject: [PATCH] fix warnings --- src/core/observer.rs | 5 ++--- src/core/port.rs | 7 +------ src/grid/mod.rs | 8 +++----- src/grid/offset.rs | 5 ++--- src/main.rs | 3 +-- src/sequence/seq2idx.rs | 3 +-- src/sequence/vec_buffer.rs | 6 +++--- src/string_editor.rs | 20 ++++++++------------ src/terminal/compositor.rs | 18 +++++++----------- src/terminal/mod.rs | 4 +--- src/terminal/terminal.rs | 3 +-- 11 files changed, 30 insertions(+), 52 deletions(-) diff --git a/src/core/observer.rs b/src/core/observer.rs index 07931df..4a17aad 100644 --- a/src/core/observer.rs +++ b/src/core/observer.rs @@ -1,7 +1,6 @@ use { crate::core::View, std::{ - ops::{Deref, DerefMut}, sync::{Arc, Weak, RwLock} } }; @@ -12,7 +11,7 @@ use { <<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>> \*/ pub trait Observer : Send + Sync { - fn reset(&mut self, view: Option>) {} + fn reset(&mut self, _view: Option>) {} fn notify(&self, msg: &V::Msg); } @@ -138,7 +137,7 @@ where V: View + ?Sized, impl Observer for ResetFnObserver where V: View + ?Sized, F: Fn(Option>) + Send + Sync { - fn notify(&self, msg: &V::Msg) {} + fn notify(&self, _msg: &V::Msg) {} fn reset(&mut self, view: Option>) { (self.f)(view); } diff --git a/src/core/port.rs b/src/core/port.rs index 7ba8a25..fc9da84 100644 --- a/src/core/port.rs +++ b/src/core/port.rs @@ -5,12 +5,7 @@ use { Observer, ObserverBroadcast, NotifyFnObserver, - ResetFnObserver, - channel::{ - ChannelData, - ChannelSender, - ChannelReceiver - } + ResetFnObserver } }; diff --git a/src/grid/mod.rs b/src/grid/mod.rs index 75100e6..7e67dce 100644 --- a/src/grid/mod.rs +++ b/src/grid/mod.rs @@ -1,12 +1,10 @@ use { std::{ - sync::{Arc, RwLock}, - ops::{Deref, Range} + ops::{Range} }, - cgmath::{Point2, Vector2}, + cgmath::{Point2}, crate::{ - core::View, - index::{IndexView, ImplIndexView} + index::{IndexView} } }; diff --git a/src/grid/offset.rs b/src/grid/offset.rs index 3119284..ae5928d 100644 --- a/src/grid/offset.rs +++ b/src/grid/offset.rs @@ -1,7 +1,6 @@ use { std::{ - sync::{Arc, RwLock}, - boxed::Box + sync::{Arc, RwLock} }, cgmath::{Point2, Vector2}, crate::{ @@ -13,7 +12,7 @@ use { InnerViewPort }, index::{IndexView}, - grid::{GridView, GridWindowIterator} + grid::{GridView} } }; diff --git a/src/main.rs b/src/main.rs index 032d4d3..878bba1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,8 +12,7 @@ pub mod string_editor; use { async_std::{task}, std::{ - sync::{Arc, RwLock}, - ops::Range + sync::{Arc, RwLock} }, cgmath::{Vector2, Point2}, termion::event::{Event, Key}, diff --git a/src/sequence/seq2idx.rs b/src/sequence/seq2idx.rs index 699abc0..78134cd 100644 --- a/src/sequence/seq2idx.rs +++ b/src/sequence/seq2idx.rs @@ -1,7 +1,6 @@ use { std::{ - sync::{Arc, RwLock}, - boxed::Box + sync::{Arc, RwLock} }, crate::{ core::{ diff --git a/src/sequence/vec_buffer.rs b/src/sequence/vec_buffer.rs index 91f003f..3543b9e 100644 --- a/src/sequence/vec_buffer.rs +++ b/src/sequence/vec_buffer.rs @@ -68,12 +68,12 @@ where T: Clone + Send + Sync + 'static { self.cast.notify(&idx); *self.cur_len.write().unwrap() -= 1; }, - VecDiff::Insert{ idx, val } => { + VecDiff::Insert{ idx, val: _ } => { let mut l = self.cur_len.write().unwrap(); *l += 1; - //self.cast.notify_each(idx .. &*l); + self.cast.notify_each(*idx .. *l); }, - VecDiff::Update{ idx, val } => { + VecDiff::Update{ idx, val: _ } => { self.cast.notify(&idx); } } diff --git a/src/string_editor.rs b/src/string_editor.rs index b8b5fd4..91c6d72 100644 --- a/src/string_editor.rs +++ b/src/string_editor.rs @@ -1,23 +1,17 @@ use { std::{ - boxed::Box, sync::{Arc, RwLock}, }, cgmath::Point2, crate::{ core::{ - View, - Observer, ObserverExt, ObserverBroadcast, - ViewPort, - InnerViewPort, - OuterViewPort + InnerViewPort }, - sequence::SequenceView, index::{ImplIndexView}, - grid::{GridView, GridWindowIterator}, + grid::{GridWindowIterator}, terminal::{TerminalAtom, TerminalStyle, TerminalView}, //vec_buffer::VecBuffer } @@ -124,11 +118,12 @@ impl StringEditor { pub fn insert(&mut self, c: char) { self.cast.notify_each({ - let mut state = self.state.write().unwrap(); + let state = self.state.write().unwrap(); let mut data = state.data.write().unwrap(); data.insert(state.cursor, c); - (state.cursor .. data.len()+2) + + state.cursor .. data.len()+2 }.map(|idx| Point2::new(1+idx as i16, 0))); self.next(); @@ -136,13 +131,14 @@ impl StringEditor { pub fn delete(&mut self) { self.cast.notify_each({ - let mut state = self.state.write().unwrap(); + let state = self.state.write().unwrap(); let mut data = state.data.write().unwrap(); if state.cursor < data.len() { data.remove(state.cursor); } - (state.cursor .. data.len()+3) + + state.cursor .. data.len()+3 }.map(|idx| Point2::new(1+idx as i16, 0))); } } diff --git a/src/terminal/compositor.rs b/src/terminal/compositor.rs index 05d63b9..a4fc0cb 100644 --- a/src/terminal/compositor.rs +++ b/src/terminal/compositor.rs @@ -1,15 +1,12 @@ use { std::{ sync::{Arc, Weak, RwLock}, - collections::HashMap, - boxed::Box, - cmp::{min, max} + collections::HashMap }, cgmath::Point2, crate::{ - core::{View, ViewPort, InnerViewPort, OuterViewPort, Observer, ObserverExt, ObserverBroadcast}, + core::{InnerViewPort, OuterViewPort, Observer, ObserverExt, ObserverBroadcast}, index::{ImplIndexView}, - grid::{GridWindowIterator}, terminal::{TerminalAtom, TerminalView} } }; @@ -24,7 +21,7 @@ impl Observer for CompositeLayer { let comp = self.comp.upgrade().unwrap(); let mut c = comp.write().unwrap(); - let mut v = &mut c.layers.get_mut(&self.idx).unwrap().1; + let v = &mut c.layers.get_mut(&self.idx).unwrap().1; let old_view = v.clone(); *v = view.clone(); drop(v); @@ -64,11 +61,11 @@ impl TerminalCompositeView { fn update_range(&mut self) { self.area = Some(Vec::new()); - for (idx, layer) in self.layers.iter() { + for (_, layer) in self.layers.iter() { if let Some(view) = layer.1.as_ref() { if let ( Some(mut new_area), - Some(mut area) + Some(area) ) = ( view.area(), self.area.as_mut() @@ -120,8 +117,7 @@ impl ImplIndexView for TerminalCompositeView { } pub struct TerminalCompositor { - view: Arc>, - port: InnerViewPort + view: Arc> } impl TerminalCompositor { @@ -138,7 +134,7 @@ impl TerminalCompositor { )); port.set_view(Some(view.clone())); - TerminalCompositor{ view, port } + TerminalCompositor{ view } } pub fn push(&mut self, v: OuterViewPort) { diff --git a/src/terminal/mod.rs b/src/terminal/mod.rs index 40f350d..1d02f02 100644 --- a/src/terminal/mod.rs +++ b/src/terminal/mod.rs @@ -13,9 +13,7 @@ pub use { use { crate::{ grid::GridView - }, - cgmath::Point2, - std::ops::Range + } }; //<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>> diff --git a/src/terminal/terminal.rs b/src/terminal/terminal.rs index d01689a..b1b4ce8 100644 --- a/src/terminal/terminal.rs +++ b/src/terminal/terminal.rs @@ -26,8 +26,7 @@ use { set_channel } }, - index::IndexView, - grid::{GridView, GridWindowIterator} + grid::{GridWindowIterator} }, super::{ TerminalStyle,