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

@ -31,28 +31,28 @@ interface (Sequence ) 0 1");
let mut f0 = unsafe { File::from_raw_fd(0) };
eprintln!("
> 0: n
>0: n
( )
( MachineInt )
( MachineWord )
( Pipe Shot MachineWord )
( Stream MachineSyllab )
");
let mut f1 = unsafe { File::from_raw_fd(1) };
eprintln!("
< 1: n'th fibonacci number
<1: n'th fibonacci number
( )
( MachineInt )
( MachineWord )
( Pipe Shot MachineWord )
( Stream MachineSyllab )
");
nested::magic_header();
let mut bytes = [0 as u8; 8];
f0.read_exact(&mut bytes);
f0.read_exact(&mut bytes).expect("");
let n = u64::from_le_bytes(bytes);
bytes = fib(n).to_le_bytes();
f1.write(&bytes);
f1.write(&bytes).expect("");
}

View file

@ -1,7 +1,7 @@
use std::{
fs::File,
io::{Read, Write},
io::{Read},
os::unix::io::FromRawFd
};
@ -32,7 +32,7 @@ fn main() {
nested::magic_header();
let mut bytes = [0 as u8; 8];
f0.read_exact(&mut bytes);
f0.read_exact(&mut bytes).expect("");
println!("{}", u64::from_le_bytes(bytes));
}

View file

@ -1,18 +1,11 @@
use {
std::sync::{Arc, RwLock},
nested::{
core::{
View,
ViewPort,
Observer,
ObserverBroadcast,
InnerViewPort,
OuterViewPort,
TypeTerm,
TypeDict
},
sequence::{SequenceView, VecBuffer},
sequence::{VecBuffer},
integer::{RadixProjection}
}
};
@ -102,7 +95,7 @@ async fn main() {
let mut src_digits = VecBuffer::<usize>::new(src_digits_port.inner());
let proj = RadixProjection::new(
let _proj = RadixProjection::new(
src_radix,
dst_radix,
src_digits_port.outer().to_sequence(),
@ -110,10 +103,8 @@ async fn main() {
);
// output dst digits
let writer = {
let _writer = {
use std::{
fs::File,
io::{Read, Write},
os::unix::io::FromRawFd
};
@ -123,8 +114,6 @@ async fn main() {
// start reading src digits
{
use async_std::{
fs::File,
io::{Read, Write},
os::unix::io::FromRawFd
};

View file

@ -53,8 +53,8 @@ $1: radix
}
let mut chars = Vec::new();
f0.read_to_end(&mut chars);
f0.read_to_end(&mut chars).expect("");
chars.retain(|c| (*c as char).is_alphanumeric());
f1.write(&u64::from_str_radix(&String::from_utf8_lossy(&chars), radix).unwrap().to_le_bytes());
f1.write(&u64::from_str_radix(&String::from_utf8_lossy(&chars), radix).unwrap().to_le_bytes()).expect("");
}

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;
}
pub fn map<U: Send + Sync + 'static>(&self, f: impl Fn(T) -> U) -> OuterViewPort<dyn SingletonView<Item = U>> {
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()
}
}
*/
*/

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);
}

View file

@ -4,7 +4,7 @@ use {
std::{
fs::File,
os::unix::io::FromRawFd,
io::{Read, Write, stdin, stdout}
io::{Read, Write, stdin}
},
nested::{
terminal::{
@ -39,7 +39,7 @@ struct PerfAtom {
impl PerfAtom {
fn write_atom(&mut self, pos: Point2<i16>, atom: Option<TerminalAtom>) {
self.out.write(&bincode::serialize(&(pos, atom)).unwrap());
self.out.write(&bincode::serialize(&(pos, atom)).unwrap()).expect("");
}
}

View file

@ -1,7 +1,5 @@
use {
std::{
fs::File,
os::unix::io::FromRawFd,
io::{Read, Write, stdout}
},
nested::terminal::{
@ -22,12 +20,7 @@ fn main() {
let mut cur_pos = Point2::<i16>::new(0, 0);
let mut cur_style = TerminalStyle::default();
let mut f = unsafe { File::from_raw_fd(0) };
let mut bytes = [0 as u8; 0xe];
let mut input = std::io::stdin();
let mut buf = [0; 2048];
loop {
match bincode::deserialize_from::<_, (Point2<i16>, Option<TerminalAtom>)>(input.by_ref()) {
@ -39,12 +32,12 @@ fn main() {
if let Some(atom) = atom {
if cur_style != atom.style {
cur_style = atom.style;
write!(out, "{}", atom.style);
write!(out, "{}", atom.style).expect("");
}
write!(out, "{}", atom.c.unwrap_or(' '));
write!(out, "{}", atom.c.unwrap_or(' ')).expect("");
} else {
write!(out, "{} ", termion::style::Reset);
write!(out, "{} ", termion::style::Reset).expect("");
cur_style = TerminalStyle::default();
}
@ -54,11 +47,11 @@ fn main() {
}
Err(err) => {
match *err {
bincode::ErrorKind::Io(io_error) => {
bincode::ErrorKind::Io(_io_error) => {
break
}
err => {
eprintln!("deserialization error: {:?}\n{:?}", bytes, err);
eprintln!("deserialization error\n{:?}", err);
}
}
break;