Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reference to HugrView is not a HugrView #1636

Open
acl-cqc opened this issue Nov 6, 2024 · 0 comments
Open

Reference to HugrView is not a HugrView #1636

acl-cqc opened this issue Nov 6, 2024 · 0 comments

Comments

@acl-cqc
Copy link
Contributor

acl-cqc commented Nov 6, 2024

All(?) the methods in HugrView take &self, so to use it, h: &impl HugrView is all you need - easy for functions. However, for structs/storage, you have to decide between MyStruct<H:HugrView>{ h: H .... }, or MyStruct<'a, H:HugrView> { h: &'a H ... }, which is awkward and inflexible.

In practice this will probably mean replacing the current impl<T:AsRef<Hugr>> HugrView for T with two impls:

impl HugrView for Hugr { ... }
impl<T: HugrView> HugrView for &T

(possibly three, for &mut T, if we extend this to HugrMut, which we may want to too, although perhaps less important). Unfortunately this means more code/duplication, but the current situation is awkward for (increasing numbers of) clients....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant