From be7cd75e4dfddb3873ab220f869bbb6d33ad8530 Mon Sep 17 00:00:00 2001 From: Hyeon Kim Date: Mon, 23 Sep 2024 02:58:29 +0900 Subject: [PATCH] obj-rs: Derive more std traits Reference: https://rust-lang.github.io/api-guidelines/interoperability.html --- obj-rs/src/error.rs | 2 +- obj-rs/src/lib.rs | 2 +- obj-rs/src/raw/lexer.rs | 1 + obj-rs/src/raw/material.rs | 2 +- obj-rs/src/raw/object.rs | 10 +++++----- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/obj-rs/src/error.rs b/obj-rs/src/error.rs index 508e048..86e95b1 100644 --- a/obj-rs/src/error.rs +++ b/obj-rs/src/error.rs @@ -78,7 +78,7 @@ impl LoadError { } /// Enum to store the various types of errors that can cause loading an OBJ to fail. -#[derive(Copy, PartialEq, Eq, Clone, Debug)] +#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] pub enum LoadErrorKind { /// Met unexpected statement. UnexpectedStatement, diff --git a/obj-rs/src/lib.rs b/obj-rs/src/lib.rs index 5e30804..2bbe2d8 100644 --- a/obj-rs/src/lib.rs +++ b/obj-rs/src/lib.rs @@ -53,7 +53,7 @@ pub fn load_obj, T: BufRead, I>(input: T) -> ObjResult { /// Object's name. diff --git a/obj-rs/src/raw/lexer.rs b/obj-rs/src/raw/lexer.rs index 2afa7cf..f07a0ca 100644 --- a/obj-rs/src/raw/lexer.rs +++ b/obj-rs/src/raw/lexer.rs @@ -25,6 +25,7 @@ fn test_strip_commect() { type StrippedLines = Map, fn(Result) -> Result>; +#[derive(Debug)] pub struct Lexer { stripped_lines: StrippedLines, } diff --git a/obj-rs/src/raw/material.rs b/obj-rs/src/raw/material.rs index ca62b66..3338309 100644 --- a/obj-rs/src/raw/material.rs +++ b/obj-rs/src/raw/material.rs @@ -126,7 +126,7 @@ fn parse_texture_map(args: &[&str]) -> ObjResult { } /// Low-level Rust binding for `.mtl` format *(incomplete)*. -#[derive(Clone, Debug)] +#[derive(Clone, PartialEq, Debug, Default)] pub struct RawMtl { /// Map from the material name to its properties pub materials: HashMap, diff --git a/obj-rs/src/raw/object.rs b/obj-rs/src/raw/object.rs index bc744cd..0e0382b 100644 --- a/obj-rs/src/raw/object.rs +++ b/obj-rs/src/raw/object.rs @@ -465,7 +465,7 @@ impl Group { } /// Low-level Rust binding for `.obj` format. -#[derive(Clone, Debug)] +#[derive(Clone, PartialEq, Debug, Default)] pub struct RawObj { /// Name of the object. pub name: Option, @@ -502,7 +502,7 @@ pub struct RawObj { pub type Point = usize; /// The `Line` type. -#[derive(PartialEq, Eq, Clone, Debug)] +#[derive(Clone, Eq, PartialEq, Hash, Debug)] pub enum Line { /// A series of line segments which contain only the position data of each vertex P(Vec), @@ -512,7 +512,7 @@ pub enum Line { } /// The `Polygon` type. -#[derive(PartialEq, Eq, Clone, Debug)] +#[derive(Clone, Eq, PartialEq, Hash, Debug)] pub enum Polygon { /// A polygon which contains only the position data of each vertex. P(Vec), @@ -525,7 +525,7 @@ pub enum Polygon { } /// A group which contains ranges of points, lines and polygons -#[derive(Clone, Debug)] +#[derive(Clone, Eq, PartialEq, Hash, Debug, Default)] pub struct Group { /// Multiple range of points pub points: Vec, @@ -536,7 +536,7 @@ pub struct Group { } /// A struct which represent `[start, end)` range. -#[derive(Copy, PartialEq, Eq, Clone, Debug)] +#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)] pub struct Range { /// The lower bound of the range (inclusive). pub start: usize,