fix warnings

This commit is contained in:
Michael Sippel 2021-05-13 16:22:30 +02:00
parent 5ec4773eb1
commit c6717e0e75
Signed by: senvas
GPG key ID: F96CF119C34B64A6
20 changed files with 87 additions and 147 deletions

View file

@ -1,13 +1,11 @@
use {
std::{
collections::HashMap,
sync::{Arc, RwLock},
any::Any
sync::{Arc, RwLock}
},
crate::{
core::{
type_term::{
TypeID,
TypeTerm,
TypeDict
},
@ -194,8 +192,8 @@ impl Object {
// replace with higher-level type in which self is a repr branch
pub fn epi_cast<'a>(
&self,
type_ladder: impl Iterator<Item = TypeTerm>,
morphism_constructors: &HashMap<MorphismType, Box<dyn Fn(Object) -> Object>>
_type_ladder: impl Iterator<Item = TypeTerm>,
_morphism_constructors: &HashMap<MorphismType, Box<dyn Fn(Object) -> Object>>
) {
// todo
}
@ -288,7 +286,6 @@ impl Context {
type_tag,
repr: Arc::new(RwLock::new(ReprTree::new()))
}
}
);
}
@ -341,8 +338,8 @@ impl Context {
typename: &str
) {
let dst_type = self.type_dict.type_term_from_str(typename).unwrap();
let mut old_obj = self.objects.get(&name.to_string()).unwrap().clone();
let mut new_obj =
let old_obj = self.objects.get(&name.to_string()).unwrap().clone();
let new_obj =
if let Some(ctor) = self.morphism_constructors.get(
&MorphismType {
mode: MorphismMode::Epi,
@ -387,29 +384,6 @@ impl Context {
None
}
}
/*
pub fn _default_repr<'a>(
&mut self,
name: &String,
type_ladder: impl Iterator<Item = &'a str>
) -> AnyOuterViewPort {
for (i, type_term) in type_ladder.rev().enumerate() {
match i {
0 => {
if let Some(constructor) = self.default_constructors.get(&type_term) {
self.add_repr()
} else {
panic!("cannot find matching default constructor!");
}
}
_n => {
}
}
}
}
*/
}
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>

View file

@ -1,10 +1,6 @@
use {
std::{
sync::Arc,
any::Any,
ops::Deref,
collections::HashMap,
iter::Peekable
collections::HashMap
},
crate::{
bimap::Bimap,
@ -32,7 +28,7 @@ impl TypeTerm {
}
pub fn arg(&mut self, t: TypeTerm) -> &mut Self {
if let TypeTerm::Type{ id, args } = self {
if let TypeTerm::Type{ id: _, args } = self {
args.push(t);
}
@ -54,7 +50,7 @@ impl TypeTerm {
")" => {
let t = term_stack.pop().unwrap();
if term_stack.len() > 0 {
let mut f = term_stack.last_mut().unwrap();
let f = term_stack.last_mut().unwrap();
if let Some(f) = f {
f.arg(t.unwrap());
} else {
@ -65,7 +61,7 @@ impl TypeTerm {
}
},
atom => {
let mut f = term_stack.last_mut().unwrap();
let f = term_stack.last_mut().unwrap();
match f {
Some(f) =>

View file

@ -1,7 +1,7 @@
use {
std::sync::{Arc, RwLock},
crate::{
core::{InnerViewPort, OuterViewPort, ObserverBroadcast},
core::{InnerViewPort, OuterViewPort},
sequence::{SequenceView, VecBuffer},
projection::ProjectionHelper
}
@ -43,7 +43,7 @@ pub struct Add {
a: Arc<dyn SequenceView<Item = usize>>, // PosInt, Little Endian
b: Arc<dyn SequenceView<Item = usize>>, // PosInt, Little Endian
c: VecBuffer<usize>,
proj_helper: ProjectionHelper<Self>
_proj_helper: ProjectionHelper<Self>
}
impl Add {
@ -60,7 +60,7 @@ impl Add {
a: proj_helper.new_sequence_arg(a, |s: &mut Self, _digit_idx| s.update()),
b: proj_helper.new_sequence_arg(b, |s: &mut Self, _digit_idx| s.update()),
c: VecBuffer::new(c),
proj_helper
_proj_helper: proj_helper
}
));
add

View file

@ -2,10 +2,7 @@ use {
std::sync::{Arc, RwLock},
crate::{
core::{
View,
ViewPort,
Observer,
ObserverBroadcast,
InnerViewPort,
OuterViewPort
},
@ -63,7 +60,7 @@ impl RadixProjection {
}
}
fn update_dst_digit(&mut self, idx: usize) {
fn _update_dst_digit(&mut self, _idx: usize) {
/*
let v = 0; // calculate new digit value
@ -85,7 +82,7 @@ impl Observer<dyn SequenceView<Item = usize>> for RadixProjection {
self.src_digits = view;
}
fn notify(&self, idx: &usize) {
fn notify(&self, _idx: &usize) {
// todo:
// src digit i changed.
// which dst-digits does it affect?

View file

@ -1,7 +1,6 @@
use {
std::{
sync::{Arc},
collections::HashSet
sync::{Arc}
},
std::sync::RwLock,
cgmath::Point2,
@ -9,7 +8,7 @@ use {
core::{ViewPort, Observer, ObserverExt, ObserverBroadcast, InnerViewPort, OuterViewPort},
index::{ImplIndexView},
terminal::{TerminalAtom, TerminalView, TerminalStyle},
projection::{ProjectionHelper, ProjectionArg}
projection::{ProjectionHelper}
}
};

View file

@ -1,5 +1,4 @@
#![feature(trait_alias)]
#![feature(non_ascii_idents)]
pub mod core;
pub mod projection;

View file

@ -9,7 +9,16 @@ use {
},
std::sync::RwLock,
crate::{
core::{View, Observer, ObserverExt, OuterViewPort, channel::{channel, ChannelData, ChannelSender, ChannelReceiver}},
core::{
View,
Observer, ObserverExt,
OuterViewPort,
channel::{
channel,
ChannelData,
ChannelSender
}
},
singleton::{SingletonView},
sequence::{SequenceView},
index::{IndexView}
@ -90,14 +99,7 @@ impl<P: Send + Sync + 'static> ProjectionHelper<P> {
async_std::task::spawn(async move {
while let Some(msg) = rx.next().await {
if let Some(proj) = proj.read().unwrap().upgrade() {
loop {
if let Ok(p) = proj.try_write().as_mut() {
notify(&mut *p, &msg);
break;
}
async_std::task::yield_now();
}
notify(&mut *proj.write().unwrap(), &msg);
}
}
});

View file

@ -1,13 +1,13 @@
use {
async_std::stream::StreamExt,
std::{
sync::{Arc, Weak},
sync::{Arc},
collections::{HashMap, HashSet}
},
std::sync::RwLock,
crate::{
core::{
View, Observer, ObserverExt, ObserverBroadcast,
View, Observer, ObserverBroadcast, ObserverExt,
ViewPort, InnerViewPort, OuterViewPort,
channel::{ChannelSender, ChannelReceiver}
},
@ -34,7 +34,7 @@ where V1: SequenceView<Item = OuterViewPort<V2>> + ?Sized + 'static,
top: Arc<RwLock<TopObserver<V1, V2>>>,
chunks: HashMap<usize, Arc<RwLock<BotObserver<V2>>>>,
cast: Arc<RwLock<ObserverBroadcast<dyn SequenceView<Item = V2::Item>>>>
_cast: Arc<RwLock<ObserverBroadcast<dyn SequenceView<Item = V2::Item>>>>
}
struct TopObserver<V1, V2>
@ -130,7 +130,7 @@ where V1: SequenceView<Item = OuterViewPort<V2>> + ?Sized + 'static,
length: 0,
top: top_obs.clone(),
chunks: HashMap::new(),
cast: out_port.get_broadcast()
_cast: out_port.get_broadcast()
}));
let f = flat.clone();

View file

@ -5,7 +5,7 @@ use {
sequence::{SequenceView},
core::{
Observer, ObserverExt, ObserverBroadcast,
View, ViewPort, InnerViewPort, OuterViewPort
View, ViewPort, OuterViewPort
}
}
};

View file

@ -7,7 +7,7 @@ use {
std::sync::RwLock,
async_std::{
io::{Read, ReadExt},
stream::{Stream, StreamExt}
stream::{StreamExt}
},
serde::{Serialize, Deserialize, de::DeserializeOwned},
crate::{
@ -101,24 +101,24 @@ where T: Clone + Serialize + Send + Sync + 'static,
self.data = view;
let mut out = self.out.write().unwrap();
out.write(&bincode::serialized_size(&VecDiff::<T>::Clear).unwrap().to_le_bytes());
out.write(&bincode::serialize(&VecDiff::<T>::Clear).unwrap());
out.write(&bincode::serialized_size(&VecDiff::<T>::Clear).unwrap().to_le_bytes()).expect("");
out.write(&bincode::serialize(&VecDiff::<T>::Clear).unwrap()).expect("");
if let Some(data) = self.data.as_ref() {
for x in data.read().unwrap().iter() {
out.write(&bincode::serialized_size(&VecDiff::Push(x)).unwrap().to_le_bytes());
out.write(&bincode::serialize(&VecDiff::Push(x)).unwrap());
out.write(&bincode::serialized_size(&VecDiff::Push(x)).unwrap().to_le_bytes()).expect("");
out.write(&bincode::serialize(&VecDiff::Push(x)).unwrap()).expect("");
}
}
out.flush();
out.flush().expect("");
}
fn notify(&self, diff: &VecDiff<T>) {
let mut out = self.out.write().unwrap();
out.write(&bincode::serialized_size(diff).unwrap().to_le_bytes());
out.write(&bincode::serialize(diff).unwrap());
out.flush();
out.write(&bincode::serialized_size(diff).unwrap().to_le_bytes()).expect("");
out.write(&bincode::serialize(diff).unwrap()).expect("");
out.flush().expect("");
}
}
@ -129,23 +129,23 @@ where T: Clone + Serialize + Send + Sync + 'static,
fn reset(&mut self, view: Option<Arc<RwLock<Vec<T>>>>) {
self.data = view;
self.out.write().unwrap().write(&serde_json::to_string(&VecDiff::<T>::Clear).unwrap().as_bytes());
self.out.write().unwrap().write(b"\n");
self.out.write().unwrap().write(&serde_json::to_string(&VecDiff::<T>::Clear).unwrap().as_bytes()).expect("");
self.out.write().unwrap().write(b"\n").expect("");
if let Some(data) = self.data.as_ref() {
for x in data.read().unwrap().iter() {
self.out.write().unwrap().write(&serde_json::to_string(&VecDiff::Push(x)).unwrap().as_bytes());
self.out.write().unwrap().write(b"\n");
self.out.write().unwrap().write(&serde_json::to_string(&VecDiff::Push(x)).unwrap().as_bytes()).expect("");
self.out.write().unwrap().write(b"\n").expect("");
}
}
self.out.write().unwrap().flush();
self.out.write().unwrap().flush().expect("");
}
fn notify(&self, diff: &VecDiff<T>) {
self.out.write().unwrap().write(serde_json::to_string(diff).unwrap().as_bytes());
self.out.write().unwrap().write(b"\n");
self.out.write().unwrap().flush();
self.out.write().unwrap().write(serde_json::to_string(diff).unwrap().as_bytes()).expect("");
self.out.write().unwrap().write(b"\n").expect("");
self.out.write().unwrap().flush().expect("");
}
}

View file

@ -52,21 +52,14 @@ where V::Item: Default{
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>
/*
pub trait ImplSingletonView : Send + Sync {
type Item;
impl<T> OuterViewPort<dyn SingletonView<Item = T>> {
pub fn get(&self) -> T {
self.get_view().unrwap().read().unwrap().get();
}
fn get(&self) -> Self::Item;
}
impl<V: ImplSingletonView> View for V {
type Msg = ();
}
impl<V: ImplSingletonView> SingletonView for V {
type Item = V::Item;
fn get(&self) -> Self::Item {
(self as &V).get()
pub fn map<U: Send + Sync + 'static>(&self, f: impl Fn(T) -> U) -> OuterViewPort<dyn SingletonView<Item = U>> {
}
}
*/
*/

View file

@ -100,9 +100,7 @@ pub mod insert_view {
use {
std::{
sync::Arc,
cmp::{min, max},
any::Any,
collections::HashSet
cmp::{min, max}
},
cgmath::Point2,
std::sync::RwLock,
@ -113,7 +111,7 @@ pub mod insert_view {
singleton::{SingletonView},
sequence::{SequenceView},
index::{IndexView},
projection::{ProjectionHelper, ProjectionArg},
projection::{ProjectionHelper},
}
};
@ -144,7 +142,7 @@ pub mod insert_view {
if i < self.cur_pos {
TerminalAtom::from(data.get(&i)?)
} else if i == self.cur_pos {
TerminalAtom::new('|', TerminalStyle::fg_color((200, 0, 0)))
TerminalAtom::new('|', TerminalStyle::fg_color((0, 200, 0)))
} else {
TerminalAtom::from(data.get(&(i - 1))?)
}

View file

@ -1,12 +1,11 @@
use {
std::{
sync::{Arc, Weak},
collections::HashMap
sync::{Arc}
},
std::sync::RwLock,
cgmath::Point2,
crate::{
core::{InnerViewPort, OuterViewPort, Observer, ObserverExt, ObserverBroadcast},
core::{InnerViewPort, OuterViewPort, Observer, ObserverBroadcast},
index::{ImplIndexView},
terminal::{TerminalAtom, TerminalView},
projection::ProjectionHelper

View file

@ -127,7 +127,8 @@ impl Observer<dyn TerminalView> for TermOutObserver {
if let Some(view) = view {
for pos in view.area().unwrap_or(
GridWindowIterator::from(
Point2::new(0, 0) .. Point2::new(w as i16, h as i16)).collect()
Point2::new(0, 0) .. Point2::new(w as i16, h as i16)
).collect()
) {
self.dirty_pos_tx.send(pos);
}
@ -148,7 +149,7 @@ pub struct TermOutWriter {
impl TermOutWriter {
fn reset(&self) {
let mut out = self.out.write().unwrap();
write!(out, "{}", termion::clear::All).ok();
write!(out, "{}", termion::clear::All).ok();
}
}