From a69246b8d4577d2d81427c475030f626b307c92e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20Borgna?= <121866228+aborgna-q@users.noreply.github.com> Date: Fri, 1 Dec 2023 15:58:22 +0100 Subject: [PATCH] feat: `Into` for custom ops (#731) --- src/ops/custom.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/ops/custom.rs b/src/ops/custom.rs index b179a7bb2..61b489145 100644 --- a/src/ops/custom.rs +++ b/src/ops/custom.rs @@ -59,6 +59,13 @@ impl From for LeafOp { } } +impl From for OpType { + fn from(value: ExternalOp) -> Self { + let leaf: LeafOp = value.into(); + leaf.into() + } +} + impl ExternalOp { /// Name of the ExternalOp pub fn name(&self) -> SmolStr { @@ -235,6 +242,19 @@ impl OpaqueOp { } } +impl From for LeafOp { + fn from(value: OpaqueOp) -> Self { + LeafOp::CustomOp(Box::new(ExternalOp::Opaque(value))) + } +} + +impl From for OpType { + fn from(value: OpaqueOp) -> Self { + let leaf: LeafOp = value.into(); + leaf.into() + } +} + /// Resolve serialized names of operations into concrete implementation (OpDefs) where possible #[allow(dead_code)] pub fn resolve_extension_ops(