From 1b9673e3e7f28dd6773e558c357e7adfb757c604 Mon Sep 17 00:00:00 2001 From: Mikolaj Wielgus Date: Sat, 23 May 2026 19:38:01 +0200 Subject: [PATCH] Derive `From` on id types --- topola/src/compounds/component.rs | 4 ++-- topola/src/compounds/net.rs | 4 ++-- topola/src/compounds/pin.rs | 4 ++-- topola/src/layout/primitives/joint.rs | 4 ++-- topola/src/layout/primitives/polygon.rs | 4 ++-- topola/src/layout/primitives/segment.rs | 4 ++-- topola/src/layout/primitives/via.rs | 4 ++-- topola/src/navmesher.rs | 8 +++++--- 8 files changed, 19 insertions(+), 17 deletions(-) diff --git a/topola/src/compounds/component.rs b/topola/src/compounds/component.rs index 0379d97..5c8fdad 100644 --- a/topola/src/compounds/component.rs +++ b/topola/src/compounds/component.rs @@ -2,13 +2,13 @@ // // SPDX-License-Identifier: MIT OR Apache-2.0 -use derive_more::Constructor; +use derive_more::{Constructor, From}; use serde::{Deserialize, Serialize}; use crate::primitives::{JointId, PolygonId, SegmentId, ViaId}; #[derive( - Clone, Constructor, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize, + Clone, Constructor, Copy, Debug, Deserialize, Eq, From, Ord, PartialEq, PartialOrd, Serialize, )] pub struct ComponentId(usize); diff --git a/topola/src/compounds/net.rs b/topola/src/compounds/net.rs index 3c88d0f..8bdfeda 100644 --- a/topola/src/compounds/net.rs +++ b/topola/src/compounds/net.rs @@ -2,11 +2,11 @@ // // SPDX-License-Identifier: MIT OR Apache-2.0 -use derive_more::Constructor; +use derive_more::{Constructor, From}; use serde::{Deserialize, Serialize}; #[derive( - Clone, Constructor, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize, + Clone, Constructor, Copy, Debug, Deserialize, Eq, From, Ord, PartialEq, PartialOrd, Serialize, )] pub struct NetId(usize); diff --git a/topola/src/compounds/pin.rs b/topola/src/compounds/pin.rs index 35d2877..aa26c33 100644 --- a/topola/src/compounds/pin.rs +++ b/topola/src/compounds/pin.rs @@ -2,13 +2,13 @@ // // SPDX-License-Identifier: MIT OR Apache-2.0 -use derive_more::Constructor; +use derive_more::{Constructor, From}; use serde::{Deserialize, Serialize}; use crate::primitives::{JointId, PolygonId, SegmentId, ViaId}; #[derive( - Clone, Constructor, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize, + Clone, Constructor, Copy, Debug, Deserialize, Eq, From, Ord, PartialEq, PartialOrd, Serialize, )] pub struct PinId(usize); diff --git a/topola/src/layout/primitives/joint.rs b/topola/src/layout/primitives/joint.rs index e899a74..908e308 100644 --- a/topola/src/layout/primitives/joint.rs +++ b/topola/src/layout/primitives/joint.rs @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: MIT OR Apache-2.0 -use derive_more::Constructor; +use derive_more::{Constructor, From}; use rstar::{AABB, primitives::Rectangle}; use serde::{Deserialize, Serialize}; @@ -12,7 +12,7 @@ use crate::math::Vector2; use super::{SegmentId, ViaId}; #[derive( - Clone, Constructor, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize, + Clone, Constructor, Copy, Debug, Deserialize, Eq, From, Ord, PartialEq, PartialOrd, Serialize, )] pub struct JointId(usize); diff --git a/topola/src/layout/primitives/polygon.rs b/topola/src/layout/primitives/polygon.rs index 32b5a6e..eb37e4e 100644 --- a/topola/src/layout/primitives/polygon.rs +++ b/topola/src/layout/primitives/polygon.rs @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: MIT OR Apache-2.0 -use derive_more::Constructor; +use derive_more::{Constructor, From}; use rstar::{AABB, Envelope, primitives::Rectangle}; use serde::{Deserialize, Serialize}; @@ -10,7 +10,7 @@ use crate::compounds::{ComponentId, NetId, PinId}; use crate::math::Vector2; #[derive( - Clone, Constructor, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize, + Clone, Constructor, Copy, Debug, Deserialize, Eq, From, Ord, PartialEq, PartialOrd, Serialize, )] pub struct PolygonId(usize); diff --git a/topola/src/layout/primitives/segment.rs b/topola/src/layout/primitives/segment.rs index 81ccaf4..9d0c8e4 100644 --- a/topola/src/layout/primitives/segment.rs +++ b/topola/src/layout/primitives/segment.rs @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: MIT OR Apache-2.0 -use derive_more::Constructor; +use derive_more::{Constructor, From}; use rstar::primitives::Rectangle; use serde::{Deserialize, Serialize}; @@ -12,7 +12,7 @@ use crate::math::Vector2; use super::JointId; #[derive( - Clone, Constructor, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize, + Clone, Constructor, Copy, Debug, Deserialize, Eq, From, Ord, PartialEq, PartialOrd, Serialize, )] pub struct SegmentId(usize); diff --git a/topola/src/layout/primitives/via.rs b/topola/src/layout/primitives/via.rs index 8bd2d56..d1255ea 100644 --- a/topola/src/layout/primitives/via.rs +++ b/topola/src/layout/primitives/via.rs @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: MIT OR Apache-2.0 -use derive_more::Constructor; +use derive_more::{Constructor, From}; use rstar::{AABB, primitives::Rectangle}; use serde::{Deserialize, Serialize}; @@ -12,7 +12,7 @@ use crate::math::Vector2; use super::JointId; #[derive( - Clone, Constructor, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize, + Clone, Constructor, Copy, Debug, Deserialize, Eq, From, Ord, PartialEq, PartialOrd, Serialize, )] pub struct ViaId(usize); diff --git a/topola/src/navmesher.rs b/topola/src/navmesher.rs index 823bdab..78e9b6d 100644 --- a/topola/src/navmesher.rs +++ b/topola/src/navmesher.rs @@ -4,7 +4,7 @@ use dearcut::{RecordingTriangulator, VertexId}; use derive_getters::Getters; -use derive_more::Constructor; +use derive_more::{Constructor, From}; use serde::{Deserialize, Serialize}; use stable_vec::StableVec; use undoredo::Recorder; @@ -16,7 +16,7 @@ use crate::{ }; #[derive( - Clone, Constructor, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize, + Clone, Constructor, Copy, Debug, Deserialize, Eq, From, Ord, PartialEq, PartialOrd, Serialize, )] pub struct MultiObstacleId { layer: usize, @@ -37,7 +37,9 @@ impl MultiObstacleId { } } -#[derive(Clone, Constructor, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)] +#[derive( + Clone, Constructor, Debug, Deserialize, Eq, From, Ord, PartialEq, PartialOrd, Serialize, +)] pub struct MultiVertexId { layer: usize, indices: Vec,