summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJovansonlee Cesar <ivanceras@gmail.com>2020-11-25 23:45:55 +0800
committerJovansonlee Cesar <ivanceras@gmail.com>2020-11-25 23:45:55 +0800
commit2bf94a2eddff2215b5f43e21658502c98d945941 (patch)
tree4bfca9a2f02546666d9b0e2386b937a7ca2296b6
parent9801decfb1b58c2f06756cafa9fd94b75fcbfdc9 (diff)
Remove warnings
-rw-r--r--svgbob/src/buffer/cell_buffer.rs7
-rw-r--r--svgbob/src/buffer/cell_buffer/contacts.rs1
-rw-r--r--svgbob/src/buffer/cell_buffer/span.rs11
-rw-r--r--svgbob/src/buffer/fragment_buffer.rs2
-rw-r--r--svgbob/src/buffer/fragment_buffer/direction.rs2
-rw-r--r--svgbob/src/buffer/fragment_buffer/fragment.rs4
-rw-r--r--svgbob/src/buffer/fragment_buffer/fragment/arc.rs2
-rw-r--r--svgbob/src/buffer/fragment_buffer/fragment/line.rs45
-rw-r--r--svgbob/src/buffer/fragment_buffer/fragment/marker_line.rs2
-rw-r--r--svgbob/src/buffer/fragment_buffer/fragment/polygon.rs8
-rw-r--r--svgbob/src/buffer/fragment_buffer/fragment/rect.rs2
-rw-r--r--svgbob/src/buffer/fragment_buffer/fragment_tree.rs8
-rw-r--r--svgbob/src/buffer/property_buffer.rs7
-rw-r--r--svgbob/src/buffer/property_buffer/property.rs2
-rw-r--r--svgbob/src/buffer/string_buffer.rs4
-rw-r--r--svgbob/src/lib.rs2
-rw-r--r--svgbob/src/map/circle_map.rs6
-rw-r--r--svgbob/src/util.rs8
18 files changed, 53 insertions, 70 deletions
diff --git a/svgbob/src/buffer/cell_buffer.rs b/svgbob/src/buffer/cell_buffer.rs
index fd0faf4..f61e9f5 100644
--- a/svgbob/src/buffer/cell_buffer.rs
+++ b/svgbob/src/buffer/cell_buffer.rs
@@ -9,7 +9,6 @@ use itertools::Itertools;
use sauron::{
html,
html::{attributes::*, *},
- svg,
svg::{attributes::*, *},
Node,
};
@@ -142,7 +141,7 @@ impl CellBuffer {
/// calculate the appropriate size (w,h) in pixels for the whole cell buffer to fit
/// appropriately
pub(crate) fn get_size(&self, settings: &Settings) -> (f32, f32) {
- let (top_left, bottom_right) = self.bounds().unwrap_or((Cell::new(0, 0), Cell::new(0, 0)));
+ let (_top_left, bottom_right) = self.bounds().unwrap_or((Cell::new(0, 0), Cell::new(0, 0)));
let w = settings.scale * (bottom_right.x + 2) as f32 * Cell::width();
let h = settings.scale * (bottom_right.y + 2) as f32 * Cell::height();
(w, h)
@@ -177,7 +176,7 @@ impl CellBuffer {
.into_iter()
.map(|contact| contact.0)
.map(move |contacts| {
- let mut group_members = contacts
+ let group_members = contacts
.iter()
.map(move |gfrag| {
let scaled = gfrag.scale(settings.scale);
@@ -192,7 +191,7 @@ impl CellBuffer {
let mut fragments: Vec<Fragment> = vec_fragments.into_iter().flatten().collect();
fragments.extend(single_member_fragments);
fragments.extend(self.escaped_text_nodes());
- let mut svg_node = Self::fragments_to_node(fragments, self.legend_css(), settings, w, h)
+ let svg_node = Self::fragments_to_node(fragments, self.legend_css(), settings, w, h)
.add_children(group_nodes);
(svg_node, w, h)
}
diff --git a/svgbob/src/buffer/cell_buffer/contacts.rs b/svgbob/src/buffer/cell_buffer/contacts.rs
index cb72770..dc832d4 100644
--- a/svgbob/src/buffer/cell_buffer/contacts.rs
+++ b/svgbob/src/buffer/cell_buffer/contacts.rs
@@ -2,7 +2,6 @@ use super::endorse;
use crate::buffer::{fragment::Fragment, Cell};
use std::{
fmt,
- ops::{Deref, DerefMut},
};
/// Contains a group of fragments that are touching each other
diff --git a/svgbob/src/buffer/cell_buffer/span.rs b/svgbob/src/buffer/cell_buffer/span.rs
index c8b3c81..a7da383 100644
--- a/svgbob/src/buffer/cell_buffer/span.rs
+++ b/svgbob/src/buffer/cell_buffer/span.rs
@@ -1,11 +1,6 @@
use crate::{
- buffer::{
- cell_buffer::Contacts,
- fragment_buffer::fragment::{marker_line, Line, Polygon, PolygonTag},
- CellGrid, FragmentBuffer, Property, PropertyBuffer, StringBuffer,
- },
+ buffer::{cell_buffer::Contacts, FragmentBuffer, Property, PropertyBuffer, StringBuffer},
fragment,
- fragment::{Circle, Marker},
map::{circle_map, UNICODE_FRAGMENTS},
Cell, Fragment, Settings,
};
@@ -204,9 +199,9 @@ impl Span {
let (top_left, _) = self.bounds().expect("mut have bounds");
let groups: Vec<Contacts> = self.get_contacts(settings);
// 1st phase, successful_endorses fragments, unendorsed one)
- let (mut fragments, mut un_endorsed) = Self::endorse_rects(groups);
+ let (mut fragments, un_endorsed) = Self::endorse_rects(groups);
// 2nd phase, try to endorse to circles and arcs from the rejects of the 1st phase
- let (mut circle_fragments, mut un_endorsed) = Self::endorse_circles_and_arcs(un_endorsed);
+ let (circle_fragments, un_endorsed) = Self::endorse_circles_and_arcs(un_endorsed);
fragments.extend(circle_fragments);
(
diff --git a/svgbob/src/buffer/fragment_buffer.rs b/svgbob/src/buffer/fragment_buffer.rs
index 39846f5..90e833d 100644
--- a/svgbob/src/buffer/fragment_buffer.rs
+++ b/svgbob/src/buffer/fragment_buffer.rs
@@ -98,7 +98,7 @@ impl FragmentBuffer {
}
pub(crate) fn get_size(&self, settings: &Settings) -> (f32, f32) {
- let (top_left, bottom_right) = self.bounds().unwrap_or((Cell::new(0, 0), Cell::new(0, 0)));
+ let (_top_left, bottom_right) = self.bounds().unwrap_or((Cell::new(0, 0), Cell::new(0, 0)));
let w = settings.scale * (bottom_right.x + 2) as f32 * Cell::width();
let h = settings.scale * (bottom_right.y + 2) as f32 * Cell::height();
(w, h)
diff --git a/svgbob/src/buffer/fragment_buffer/direction.rs b/svgbob/src/buffer/fragment_buffer/direction.rs
index 3eedaa8..2a2255c 100644
--- a/svgbob/src/buffer/fragment_buffer/direction.rs
+++ b/svgbob/src/buffer/fragment_buffer/direction.rs
@@ -1,5 +1,5 @@
use crate::buffer::CellGrid;
-use crate::fragment::PolygonTag;
+
#[derive(Debug, Clone, PartialEq, Copy)]
pub enum Direction {
diff --git a/svgbob/src/buffer/fragment_buffer/fragment.rs b/svgbob/src/buffer/fragment_buffer/fragment.rs
index 6795558..113b1d2 100644
--- a/svgbob/src/buffer/fragment_buffer/fragment.rs
+++ b/svgbob/src/buffer/fragment_buffer/fragment.rs
@@ -6,7 +6,7 @@ pub use line::Line;
pub use marker_line::{Marker, MarkerLine};
pub use polygon::{Polygon, PolygonTag};
pub use rect::Rect;
-use sauron::{html::attributes::class, Node};
+use sauron::{Node};
use std::{cmp::Ordering, fmt};
pub use text::{CellText, Text};
@@ -604,7 +604,7 @@ mod tests {
let c = CellGrid::c();
let m = CellGrid::m();
let w = CellGrid::w();
- let mut fragments1 = vec![line(k, m), line(m, o), line(c, m), line(m, w)];
+ let fragments1 = vec![line(k, m), line(m, o), line(c, m), line(m, w)];
println!("before merged:");
for frag in &fragments1 {
println!("{}", frag);
diff --git a/svgbob/src/buffer/fragment_buffer/fragment/arc.rs b/svgbob/src/buffer/fragment_buffer/fragment/arc.rs
index 12a477e..d7a31bc 100644
--- a/svgbob/src/buffer/fragment_buffer/fragment/arc.rs
+++ b/svgbob/src/buffer/fragment_buffer/fragment/arc.rs
@@ -96,7 +96,7 @@ impl Arc {
|| self.end == other.start
}
- pub(in crate) fn has_endpoint(&self, p: Point) -> bool {
+ pub fn has_endpoint(&self, p: Point) -> bool {
self.start == p || self.end == p
}
diff --git a/svgbob/src/buffer/fragment_buffer/fragment/line.rs b/svgbob/src/buffer/fragment_buffer/fragment/line.rs
index 93c0ed4..701988c 100644
--- a/svgbob/src/buffer/fragment_buffer/fragment/line.rs
+++ b/svgbob/src/buffer/fragment_buffer/fragment/line.rs
@@ -1,8 +1,5 @@
use crate::{
- buffer::{
- fragment_buffer::fragment::{polygon::Polygon, PolygonTag},
- Cell, CellGrid, Fragment,
- },
+ buffer::{fragment_buffer::fragment::polygon::Polygon, Cell, Fragment},
fragment::{marker_line, Bounds, Circle, Marker, MarkerLine},
util, Direction, Point,
};
@@ -14,12 +11,7 @@ use ncollide2d::{
use std::{cmp::Ordering, fmt};
use crate::fragment::Arc;
-use sauron::{
- html::attributes::*,
- svg,
- svg::{attributes::*, *},
- Node,
-};
+use sauron::{html::attributes::*, svg, svg::attributes::*, Node};
#[derive(Debug, Clone)]
pub struct Line {
@@ -142,21 +134,21 @@ impl Line {
///
///
fn line_angle(&self) -> f32 {
- let angle = self.full_angle();
+ let angle = self.full_angle().round() as i32;
match angle {
- 0.0..=10.0 => 0.0,
- 10.0..=50.0 => 63.435, //45.0,
- 50.0..=80.0 => 63.435,
- 80.0..=100.0 => 90.0,
- 100.0..=130.0 => 116.565,
- 130.0..=170.0 => 116.565, //135.0,
- 170.0..=190.0 => 180.0,
- 190.0..=230.0 => 243.435, //225.0,
- 230.0..=260.0 => 243.435,
- 260.0..=280.0 => 270.0,
- 280.0..=310.0 => 296.565,
- 310.0..=350.0 => 296.565, //315.0,
- 350.0..=360.0 => 0.0,
+ 0..=10 => 0.0,
+ 11..=50 => 63.435, //45.0,
+ 51..=80 => 63.435,
+ 81..=100 => 90.0,
+ 101..=130 => 116.565,
+ 131..=170 => 116.565, //135.0,
+ 171..=190 => 180.0,
+ 191..=230 => 243.435, //225.0,
+ 231..=260 => 243.435,
+ 261..=280 => 270.0,
+ 281..=310 => 296.565,
+ 311..=350 => 296.565, //315.0,
+ 351..=360 => 0.0,
_ => 0.0,
}
}
@@ -212,6 +204,7 @@ impl Line {
}
*/
+ #[allow(unused)]
pub(crate) fn merge_marker_line(&self, mline: &MarkerLine) -> Option<Fragment> {
if mline.start_marker.is_none() {
if self.end == mline.line.start {
@@ -265,7 +258,7 @@ impl Line {
let distance_end_center = self.end.distance(&center);
let distance_start_center = self.start.distance(&center);
- let threshold_length = self.heading().threshold_length();
+ let _threshold_length = self.heading().threshold_length();
let is_close_start_point = distance_start_center < (circle.radius);
let is_close_end_point = distance_end_center < (circle.radius);
is_close_start_point || is_close_end_point
@@ -324,7 +317,7 @@ impl Line {
} else {
panic!("There is no endpoint of the line is that close to the arrow");
};
- let mut extended_line = new_line.extend(threshold_length);
+ let extended_line = new_line.extend(threshold_length);
Some(marker_line(
extended_line.start,
diff --git a/svgbob/src/buffer/fragment_buffer/fragment/marker_line.rs b/svgbob/src/buffer/fragment_buffer/fragment/marker_line.rs
index 98e6e62..7ebb273 100644
--- a/svgbob/src/buffer/fragment_buffer/fragment/marker_line.rs
+++ b/svgbob/src/buffer/fragment_buffer/fragment/marker_line.rs
@@ -166,7 +166,7 @@ impl fmt::Display for MarkerLine {
impl<MSG> Into<Node<MSG>> for MarkerLine {
fn into(self) -> Node<MSG> {
- let mut node: Node<MSG> = self.line.into();
+ let node: Node<MSG> = self.line.into();
let mut classes = vec![];
if let Some(start_marker) = self.start_marker {
classes.push(class(format!("start_marked_{}", start_marker)));
diff --git a/svgbob/src/buffer/fragment_buffer/fragment/polygon.rs b/svgbob/src/buffer/fragment_buffer/fragment/polygon.rs
index 91df71e..473e0ac 100644
--- a/svgbob/src/buffer/fragment_buffer/fragment/polygon.rs
+++ b/svgbob/src/buffer/fragment_buffer/fragment/polygon.rs
@@ -1,10 +1,6 @@
use crate::Direction;
use crate::{
- buffer::CellGrid,
- fragment::{
- marker_line::{Marker, MarkerLine},
- Bounds,
- },
+ fragment::{marker_line::Marker, Bounds},
Cell, Point,
};
use nalgebra::Point2;
@@ -14,7 +10,7 @@ use sauron::{
svg::{attributes::*, *},
Node,
};
-use std::{cmp::Ordering, fmt, ops::Deref};
+use std::{cmp::Ordering, fmt};
#[derive(Debug, Clone, PartialEq)]
pub enum PolygonTag {
diff --git a/svgbob/src/buffer/fragment_buffer/fragment/rect.rs b/svgbob/src/buffer/fragment_buffer/fragment/rect.rs
index 97a15e0..457d776 100644
--- a/svgbob/src/buffer/fragment_buffer/fragment/rect.rs
+++ b/svgbob/src/buffer/fragment_buffer/fragment/rect.rs
@@ -3,7 +3,7 @@ use std::fmt;
use ncollide2d::shape::{Segment, Shape};
use sauron::{
- html::{attributes, attributes::*},
+ html::{attributes::*},
svg::{attributes::*, *},
Node,
};
diff --git a/svgbob/src/buffer/fragment_buffer/fragment_tree.rs b/svgbob/src/buffer/fragment_buffer/fragment_tree.rs
index 5a0a386..139c6ae 100644
--- a/svgbob/src/buffer/fragment_buffer/fragment_tree.rs
+++ b/svgbob/src/buffer/fragment_buffer/fragment_tree.rs
@@ -1,4 +1,4 @@
-use crate::{buffer::Settings, Fragment};
+use crate::{Fragment};
use sauron::{html::attributes::*, Node};
/// A tree of fragments where a fragment can contain other fragments
@@ -102,7 +102,7 @@ impl FragmentTree {
fn into_nodes<MSG>(self) -> Vec<Node<MSG>> {
let mut nodes = vec![];
let mut fragment_node: Node<MSG> = self.fragment.into();
- let css_tag_len = self.css_tag.len();
+ let _css_tag_len = self.css_tag.len();
fragment_node = fragment_node.merge_attributes(vec![classes(self.css_tag)]);
nodes.push(fragment_node);
@@ -163,7 +163,7 @@ mod tests {
#[test]
fn test_enclose_recursive() {
- let mut rect1 = rect(Point::new(0.0, 0.0), Point::new(10.0, 10.0), false, false);
+ let rect1 = rect(Point::new(0.0, 0.0), Point::new(10.0, 10.0), false, false);
let rect2 = rect(Point::new(1.0, 1.0), Point::new(9.0, 9.0), false, false);
let text1 = Fragment::CellText(CellText::new(Cell::new(2, 2), "{doc}".to_string()));
let text2 = Fragment::CellText(CellText::new(
@@ -201,7 +201,7 @@ mod tests {
#[test]
fn test_enclose_recursive_different_order() {
- let mut rect1 = rect(Point::new(0.0, 0.0), Point::new(10.0, 10.0), false, false);
+ let rect1 = rect(Point::new(0.0, 0.0), Point::new(10.0, 10.0), false, false);
let rect2 = rect(Point::new(1.0, 1.0), Point::new(9.0, 9.0), false, false);
let text1 = Fragment::CellText(CellText::new(Cell::new(2, 2), "{doc}".to_string()));
let text2 = Fragment::CellText(CellText::new(
diff --git a/svgbob/src/buffer/property_buffer.rs b/svgbob/src/buffer/property_buffer.rs
index 1c7b907..88d03bb 100644
--- a/svgbob/src/buffer/property_buffer.rs
+++ b/svgbob/src/buffer/property_buffer.rs
@@ -6,7 +6,6 @@ use crate::{
pub use property::{Property, Signal};
use std::{
collections::HashMap,
- ops::{Deref, DerefMut},
};
mod property;
@@ -97,7 +96,7 @@ impl<'p> PropertyBuffer<'p> {
signature_match
} else {
ASCII_PROPERTIES.iter().find_map(|(ch, property)| {
- let mut behavioral_fragments = property.fragments(
+ let behavioral_fragments = property.fragments(
settings,
top_left,
top,
@@ -219,7 +218,7 @@ mod tests {
#[test]
fn test_match_char_with_surrounding_properties_with_diagonal_cross() {
let k = CellGrid::k();
- let m = CellGrid::m();
+ let _m = CellGrid::m();
let o = CellGrid::o();
let e = CellGrid::e();
let u = CellGrid::u();
@@ -259,7 +258,7 @@ mod tests {
let k = CellGrid::k();
let o = CellGrid::o();
let c = CellGrid::c();
- let m = CellGrid::m();
+ let _m = CellGrid::m();
let w = CellGrid::w();
// |
// -+-
diff --git a/svgbob/src/buffer/property_buffer/property.rs b/svgbob/src/buffer/property_buffer/property.rs
index 0e5066d..3068be9 100644
--- a/svgbob/src/buffer/property_buffer/property.rs
+++ b/svgbob/src/buffer/property_buffer/property.rs
@@ -177,7 +177,7 @@ impl Property {
/// evaluate this property together with the supplied surrounding
/// to see if the resulting fragments is equal to the supplied fragments
- pub(in crate) fn match_property(&self, fragments: &Vec<Fragment>) -> bool {
+ pub(in crate) fn match_property(&self, _fragments: &Vec<Fragment>) -> bool {
false
}
diff --git a/svgbob/src/buffer/string_buffer.rs b/svgbob/src/buffer/string_buffer.rs
index cb54cdd..c7fb9b0 100644
--- a/svgbob/src/buffer/string_buffer.rs
+++ b/svgbob/src/buffer/string_buffer.rs
@@ -1,4 +1,4 @@
-use crate::point::Point;
+
use std::ops::{Deref, DerefMut};
use unicode_width::UnicodeWidthChar;
@@ -79,7 +79,7 @@ impl From<&str> for StringBuffer {
for ch in line.chars() {
row.push(ch);
if let Some(width) = ch.width() {
- for i in 1..width {
+ for _i in 1..width {
row.push('\0');
}
}
diff --git a/svgbob/src/lib.rs b/svgbob/src/lib.rs
index 055b8e6..098c3c1 100644
--- a/svgbob/src/lib.rs
+++ b/svgbob/src/lib.rs
@@ -1,3 +1,5 @@
+#![deny(warnings)]
+#![allow(unused)]
#![deny(clippy::all)]
pub mod buffer;
diff --git a/svgbob/src/map/circle_map.rs b/svgbob/src/map/circle_map.rs
index 5367007..7558007 100644
--- a/svgbob/src/map/circle_map.rs
+++ b/svgbob/src/map/circle_map.rs
@@ -252,14 +252,14 @@ lazy_static! {
/// The fragments for each of the circle
/// Calculate the span and get the group fragments
pub static ref FRAGMENTS_CIRCLE: Vec<(Vec<Contacts>,Circle)> = Vec::from_iter(
- CIRCLE_MAP.iter().map(|(art, center_cell, center, radius)|{
+ CIRCLE_MAP.iter().map(|(art, _center_cell, center, radius)|{
(circle_art_to_group(art, &Settings::default()), Circle::new(*center, *radius, false))
})
);
/// There is only 1 span per circle, and localized
pub static ref CIRCLES_SPAN: BTreeMap<Circle, Span> = BTreeMap::from_iter(
- CIRCLE_MAP.iter().map(|(art, center_cell, center, radius)|{
+ CIRCLE_MAP.iter().map(|(art, _center_cell, center, radius)|{
let cb = CellBuffer::from(*art);
let mut spans = cb.group_adjacents();
assert_eq!(spans.len(), 1);
@@ -408,7 +408,7 @@ pub fn endorse_circle(search: &Vec<Contacts>) -> Option<(&Circle, Vec<usize>)> {
fn is_subset_of(subset: &Vec<Contacts>, big_set: &Vec<Contacts>) -> (bool, Vec<usize>) {
let mut unmatched = vec![];
let mut matched = 0;
- for (i, set) in subset.iter().enumerate() {
+ for (_i, set) in subset.iter().enumerate() {
if big_set.contains(set) {
matched += 1;
}
diff --git a/svgbob/src/util.rs b/svgbob/src/util.rs
index 2a50fab..a822be6 100644
--- a/svgbob/src/util.rs
+++ b/svgbob/src/util.rs
@@ -1,4 +1,4 @@
-use crate::{fragment::Line, Point};
+use crate::{Point};
use ncollide2d::{
bounding_volume::AABB, math::Isometry, query::point_internal::point_query::PointQuery,
};
@@ -82,8 +82,8 @@ pub fn pad(v: f32) -> f32 {
/// this is parser module which provides parsing for identifier for
/// extracting the css tag of inside of a shape fragment
pub mod parser {
- use crate::Cell;
- use pom::parser::{call, end, is_a, list, none_of, one_of, sym, tag, Parser};
+
+ use pom::parser::{is_a, list, none_of, one_of, sym, tag, Parser};
use std::iter::FromIterator;
/// Parses a list with the defined separator, but will fail early when one of the
@@ -119,7 +119,7 @@ pub mod parser {
}
}
}
- Err(e) => {
+ Err(_e) => {
// the separator does not match, just break
break;
}