From 01b2654f06a64a6e63f88bbbd10239ab26d7bc49 Mon Sep 17 00:00:00 2001 From: Agustin Borgna Date: Fri, 1 Dec 2023 14:55:02 +0000 Subject: [PATCH] feat: `Into` for custom ops --- 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(