From 0c81173c0729e97b562574d3d7b84acb95d3079a Mon Sep 17 00:00:00 2001 From: Rahul Kumar Date: Fri, 18 Oct 2024 12:42:13 -0700 Subject: [PATCH] add cell port constructor, consuming must connect setter --- substrate/src/layout/cell.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/substrate/src/layout/cell.rs b/substrate/src/layout/cell.rs index 8aec843..4b7a95f 100644 --- a/substrate/src/layout/cell.rs +++ b/substrate/src/layout/cell.rs @@ -1007,6 +1007,21 @@ impl CellPort { } } + pub fn with_shapes( + id: impl Into, + layer: LayerKey, + shapes: impl IntoIterator, + ) -> Self { + let mut map = HashMap::with_capacity(1); + let mut entry = map.entry(layer).or_insert_with(Vec::new); + entry.extend(shapes); + Self { + id: id.into(), + shapes: map, + must_connect: Default::default(), + } + } + pub fn with_element(id: impl Into, elem: Element) -> Self { let mut shapes = HashMap::with_capacity(1); shapes.insert(elem.layer.layer(), vec![elem.into_inner()]); @@ -1037,6 +1052,11 @@ impl CellPort { self } + pub fn must_connect(mut self, must_connect: impl Into) -> Self { + self.set_must_connect(must_connect); + self + } + /// Returns the ID of the port. #[inline] pub fn id(&self) -> &PortId {