Skip to content

Commit

Permalink
Lift fmt::Display requirement of Operations
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Jan 17, 2025
1 parent cb165bb commit ad2c7b4
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 54 deletions.
10 changes: 2 additions & 8 deletions experiments/2024-12-09/src/geometry/operation.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::{fmt, ops::Deref, rc::Rc};
use std::{ops::Deref, rc::Rc};

use super::tri_mesh::TriMesh;

pub trait Operation: fmt::Display {
pub trait Operation {
fn label(&self) -> &'static str;
fn tri_mesh(&self) -> TriMesh;
fn children(&self) -> Vec<AnyOp>;
Expand Down Expand Up @@ -62,12 +62,6 @@ impl AnyOp {
}
}

impl fmt::Display for AnyOp {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.inner)
}
}

impl Operation for AnyOp {
fn label(&self) -> &'static str {
self.inner.label()
Expand Down
14 changes: 0 additions & 14 deletions experiments/2024-12-09/src/geometry/shape.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::fmt;

use tuples::CombinRight;

use crate::storage::Store;
Expand All @@ -24,12 +22,6 @@ impl Shape {
}
}

impl fmt::Display for Shape {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "shape")
}
}

impl Operation for Shape {
fn label(&self) -> &'static str {
"Shape"
Expand Down Expand Up @@ -77,12 +69,6 @@ impl Operation for OperationInSequence {
}
}

impl fmt::Display for OperationInSequence {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.operation.fmt(f)
}
}

pub struct ShapeExtender<'r, NewOps, T> {
store: &'r mut Store<T>,
sequence: &'r mut Vec<OperationInSequence>,
Expand Down
8 changes: 0 additions & 8 deletions experiments/2024-12-09/src/geometry/triangle.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::fmt;

use crate::math::Point;

use super::{operation::AnyOp, Operation, TriMesh};
Expand All @@ -20,12 +18,6 @@ where
}
}

impl fmt::Display for Triangle {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "triangle")
}
}

impl Operation for Triangle {
fn label(&self) -> &'static str {
"Triangle"
Expand Down
8 changes: 0 additions & 8 deletions experiments/2024-12-09/src/topology/face.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::fmt;

use spade::Triangulation;

use crate::{
Expand Down Expand Up @@ -40,12 +38,6 @@ impl Face {
}
}

impl fmt::Display for Face {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "face")
}
}

impl Operation for Face {
fn label(&self) -> &'static str {
"Face"
Expand Down
9 changes: 0 additions & 9 deletions experiments/2024-12-09/src/topology/vertex.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::fmt;

use crate::{
geometry::{AnyOp, Operation, TriMesh},
math::Point,
Expand All @@ -21,13 +19,6 @@ where
}
}

impl fmt::Display for Vertex {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let [x, y, z] = self.point.coords.components.map(|s| s.value());
write!(f, "vertex {x:.2}, {y:.2}, {z:.2}")
}
}

impl Operation for Vertex {
fn label(&self) -> &'static str {
"Vertex"
Expand Down
8 changes: 1 addition & 7 deletions experiments/2024-12-09/src/view.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{fmt, iter};
use std::iter;

use crate::geometry::{AnyOp, Operation, TriMesh};

Expand Down Expand Up @@ -121,12 +121,6 @@ impl OperationView {
}
}

impl fmt::Display for OperationView {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.operation)
}
}

impl Operation for OperationView {
fn label(&self) -> &'static str {
self.operation.label()
Expand Down

0 comments on commit ad2c7b4

Please sign in to comment.