Lift fmt::Display requirement of Operations

This commit is contained in:
Hanno Braun 2025-01-17 20:00:57 +01:00
parent cb165bbd81
commit ad2c7b4e9a
6 changed files with 3 additions and 54 deletions

View File

@ -1,8 +1,8 @@
use std::{fmt, ops::Deref, rc::Rc}; use std::{ops::Deref, rc::Rc};
use super::tri_mesh::TriMesh; use super::tri_mesh::TriMesh;
pub trait Operation: fmt::Display { pub trait Operation {
fn label(&self) -> &'static str; fn label(&self) -> &'static str;
fn tri_mesh(&self) -> TriMesh; fn tri_mesh(&self) -> TriMesh;
fn children(&self) -> Vec<AnyOp>; fn children(&self) -> Vec<AnyOp>;
@ -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 { impl Operation for AnyOp {
fn label(&self) -> &'static str { fn label(&self) -> &'static str {
self.inner.label() self.inner.label()

View File

@ -1,5 +1,3 @@
use std::fmt;
use tuples::CombinRight; use tuples::CombinRight;
use crate::storage::Store; use crate::storage::Store;
@ -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 { impl Operation for Shape {
fn label(&self) -> &'static str { fn label(&self) -> &'static str {
"Shape" "Shape"
@ -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> { pub struct ShapeExtender<'r, NewOps, T> {
store: &'r mut Store<T>, store: &'r mut Store<T>,
sequence: &'r mut Vec<OperationInSequence>, sequence: &'r mut Vec<OperationInSequence>,

View File

@ -1,5 +1,3 @@
use std::fmt;
use crate::math::Point; use crate::math::Point;
use super::{operation::AnyOp, Operation, TriMesh}; use super::{operation::AnyOp, Operation, TriMesh};
@ -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 { impl Operation for Triangle {
fn label(&self) -> &'static str { fn label(&self) -> &'static str {
"Triangle" "Triangle"

View File

@ -1,5 +1,3 @@
use std::fmt;
use spade::Triangulation; use spade::Triangulation;
use crate::{ use crate::{
@ -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 { impl Operation for Face {
fn label(&self) -> &'static str { fn label(&self) -> &'static str {
"Face" "Face"

View File

@ -1,5 +1,3 @@
use std::fmt;
use crate::{ use crate::{
geometry::{AnyOp, Operation, TriMesh}, geometry::{AnyOp, Operation, TriMesh},
math::Point, math::Point,
@ -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 { impl Operation for Vertex {
fn label(&self) -> &'static str { fn label(&self) -> &'static str {
"Vertex" "Vertex"

View File

@ -1,4 +1,4 @@
use std::{fmt, iter}; use std::iter;
use crate::geometry::{AnyOp, Operation, TriMesh}; use crate::geometry::{AnyOp, Operation, TriMesh};
@ -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 { impl Operation for OperationView {
fn label(&self) -> &'static str { fn label(&self) -> &'static str {
self.operation.label() self.operation.label()