Skip to content

Commit

Permalink
Add Debug impl's for all public structs. (#34)
Browse files Browse the repository at this point in the history
* warn missing debug impls

* clippy fix

* Add Debug impl's

* lint rm whitespace
  • Loading branch information
cowlicks authored Oct 1, 2024
1 parent d1007bb commit 1db57fe
Show file tree
Hide file tree
Showing 14 changed files with 25 additions and 13 deletions.
7 changes: 4 additions & 3 deletions layout/src/adt/dag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use std::cmp;

/// The Ranked-DAG data structure.
#[derive(Debug)]
pub struct DAG {
/// A list of nodes in the dag.
nodes: Vec<Node>,
Expand Down Expand Up @@ -39,6 +40,7 @@ impl From<usize> for NodeHandle {
}
}

#[derive(Debug)]
struct Node {
// Points to other edges.
successors: Vec<NodeHandle>,
Expand All @@ -57,6 +59,7 @@ impl Node {
}

/// Node iterator for iterating over nodes in the graph.
#[derive(Debug)]
pub struct NodeIterator {
curr: usize,
last: usize,
Expand Down Expand Up @@ -265,9 +268,7 @@ impl DAG {
worklist.push((n, false));
}

while !worklist.is_empty() {
let (current, cmd) = worklist.pop().unwrap();

while let Some((current, cmd)) = worklist.pop() {
// Handle 'push' commands.
if cmd {
order.push(current);
Expand Down
1 change: 1 addition & 0 deletions layout/src/adt/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::hash::Hash;

/// Scoped map that supports inserting and removing lots of key-val pairs
/// at once.
#[derive(Debug)]
pub struct ScopedMap<K, V> {
stack: Vec<Vec<(K, V)>>,
}
Expand Down
1 change: 1 addition & 0 deletions layout/src/backends/svg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ fn escape_string(x: &str) -> String {
res
}

#[derive(Debug)]
pub struct SVGWriter {
content: String,
view_size: Point,
Expand Down
2 changes: 1 addition & 1 deletion layout/src/core/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ static KNOWN_COLORS: [(&str, u32); 148] = [
("yellowgreen", 0x9acd32),
];

#[derive(Clone, Copy)]
#[derive(Debug, Clone, Copy)]
pub struct Color {
// Color in the format RGBA
color: u32,
Expand Down
5 changes: 2 additions & 3 deletions layout/src/core/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
use crate::core::color::Color;

#[derive(Copy, Clone)]
#[derive(Debug, Copy, Clone)]
pub enum LineStyleKind {
Normal,
Dashed,
Dotted,
None,
}

#[derive(Clone)]

#[derive(Clone, Debug)]
pub struct StyleAttr {
pub line_color: Color,
pub line_width: usize,
Expand Down
2 changes: 2 additions & 0 deletions layout/src/gv/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type PropertyList = HashMap<String, String>;
// AST into the VisualGraph data-structure that we use for layout and rendering
// of the graph.

#[derive(Debug)]
struct EdgeDesc {
from: String,
to: String,
Expand All @@ -29,6 +30,7 @@ struct EdgeDesc {
}

/// This class constructs a visual graph from the parsed AST.
#[derive(Debug)]
pub struct GraphBuilder {
// This records the state of the top-level graph.
global_state: PropertyList,
Expand Down
1 change: 1 addition & 0 deletions layout/src/gv/parser/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub enum Token {
Error(usize),
}

#[derive(Debug)]
pub struct Lexer {
input: Vec<char>,
pub pos: usize,
Expand Down
1 change: 1 addition & 0 deletions layout/src/gv/parser/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use super::ast;
use super::lexer::Lexer;
use super::lexer::Token;

#[derive(Debug)]
pub struct DotParser {
lexer: Lexer,
tok: Token,
Expand Down
2 changes: 2 additions & 0 deletions layout/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ fn simple_graph() {
*/

#![warn(missing_debug_implementations)]

pub mod adt;
pub mod backends;
pub mod core;
Expand Down
10 changes: 5 additions & 5 deletions layout/src/std_shapes/shapes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ use crate::std_shapes::render::get_shape_size;
const PADDING: f64 = 60.;
const CONN_PADDING: f64 = 10.;

#[derive(Copy, Clone)]
#[derive(Debug, Copy, Clone)]
pub enum LineEndKind {
None,
Arrow,
}

#[derive(Clone)]
#[derive(Debug, Clone)]
pub enum RecordDef {
// Label, port:
Text(String, Option<String>),
Expand All @@ -35,7 +35,7 @@ impl RecordDef {
}
}

#[derive(Clone)]
#[derive(Debug, Clone)]
pub enum ShapeKind {
None,
Box(String),
Expand Down Expand Up @@ -66,7 +66,7 @@ impl ShapeKind {
}
}

#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct Element {
pub shape: ShapeKind,
pub pos: Position,
Expand Down Expand Up @@ -136,7 +136,7 @@ impl Element {
}
}

#[derive(Clone)]
#[derive(Debug, Clone)]
pub struct Arrow {
pub start: LineEndKind,
pub end: LineEndKind,
Expand Down
1 change: 1 addition & 0 deletions layout/src/topo/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use std::vec;

use super::placer::Placer;

#[derive(Debug)]
pub struct VisualGraph {
// Holds all of the elements in the graph.
nodes: Vec<Element>,
Expand Down
2 changes: 2 additions & 0 deletions layout/src/topo/optimizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crate::core::base::Direction;
/// This optimizations changes the order of nodes within a rank (ordering along
/// the x-axis). The transformation tries to reduce the number of edges that
/// cross each other.
#[derive(Debug)]
pub struct EdgeCrossOptimizer<'a> {
dag: &'a mut DAG,
}
Expand Down Expand Up @@ -212,6 +213,7 @@ impl<'a> EdgeCrossOptimizer<'a> {

/// This optimization sinks nodes in an attempt to shorten the length of edges
/// that run through the graph.
#[derive(Debug)]
pub struct RankOptimizer<'a> {
dag: &'a mut DAG,
}
Expand Down
2 changes: 1 addition & 1 deletion layout/src/topo/placer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub const EPSILON: f64 = 0.001;

/// Categorizes blocks to visible and invisible. We use this enum to tell the
/// passes which blocks they are allowed to touch.
#[derive(Clone, Copy)]
#[derive(Debug, Clone, Copy)]
pub enum BlockKind {
Box,
Connector,
Expand Down
1 change: 1 addition & 0 deletions layout/src/topo/placer/place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::topo::placer::move_between_rows;
use crate::topo::placer::simple;
use crate::topo::placer::verifier;

#[derive(Debug)]
pub struct Placer<'a> {
vg: &'a mut VisualGraph,
}
Expand Down

0 comments on commit 1db57fe

Please sign in to comment.