Skip to content

refactor: CustomType stores Arc<TypeDef> #2001

@acl-cqc

Description

@acl-cqc

ATM CustomType::get_type_def requires passing in the Arc<Extension> from CustomType::get_extension so that the caller keeps the Arc (upgraded from the Weak<Extension> in the typedef) alive. This is annoying for callers, and the Weak<Extension> means the Extension + TypeDefs could be collected while the CustomType remains live.

Since there is no link from the TypeDef to CustomType instances thereof, we could instead

  • Give CustomType an Arc<TypeDef> (but no direct link to the extension. The TypeDef has a Weak<Extension> which should be enough if really necessary.
  • This requires changing Extension to store Arc<TypeDef> rather than TypeDef directly
  • Drop CustomType::get_extension; remove parameters from CustomType::get_type_def

I think this is non-breaking (the CustomType methods are crate-private), might reconsider if this changes.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions