From dc85f392753ccaab9360efb68ee31798dc56a2b4 Mon Sep 17 00:00:00 2001 From: blockiosaurus <90809591+blockiosaurus@users.noreply.github.com> Date: Wed, 10 Apr 2024 10:16:21 -0400 Subject: [PATCH] Adding derive for FromPrimitive to enums. (#199) --- .changeset/grumpy-suits-tap.md | 5 +++++ src/renderers/rust/getTypeManifestVisitor.ts | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changeset/grumpy-suits-tap.md diff --git a/.changeset/grumpy-suits-tap.md b/.changeset/grumpy-suits-tap.md new file mode 100644 index 00000000..a8f471c5 --- /dev/null +++ b/.changeset/grumpy-suits-tap.md @@ -0,0 +1,5 @@ +--- +"@metaplex-foundation/kinobi": patch +--- + +Adding derive for FromPrimitive to enums. diff --git a/src/renderers/rust/getTypeManifestVisitor.ts b/src/renderers/rust/getTypeManifestVisitor.ts index 52ae5884..0d78949c 100644 --- a/src/renderers/rust/getTypeManifestVisitor.ts +++ b/src/renderers/rust/getTypeManifestVisitor.ts @@ -80,7 +80,8 @@ export function getTypeManifestVisitor() { isNode(definedType.type, 'enumTypeNode') && isScalarEnum(definedType.type) ) { - traits.push('PartialOrd', 'Hash'); + traits.push('PartialOrd', 'Hash', 'FromPrimitive'); + manifest.imports.add(['num_derive::FromPrimitive']); } return { ...manifest,