You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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....
The text was updated successfully, but these errors were encountered:
closes#1636 .
Ideally we'd like a blanket implementation over all things that Deref to
anything that's a HugrView, but AFAICS this isn't possible in Rust ATM,
although might become so in the future given constrained HRTBs
(higher-ranked type bounds). So, implement manually for `&T`, `&mut T`,
`Rc<T>`, `Arc<T>`, `Box<T>`, `Cow<...,T>` and also `RootChecked`, using
a macro in views/impls.rs.
BREAKING CHANGE: types which implement AsRef<Hugr> - both library ones
such as Rc<Hugr> and custom ones - no longer get a blanket impl of
HugrView. Workaround by manually calling `as_ref()` and using the
`&Hugr` yourself.
---------
Co-authored-by: Douglas Wilson <141026920+doug-q@users.noreply.github.com>
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 betweenMyStruct<H:HugrView>{ h: H .... }
, orMyStruct<'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:(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....The text was updated successfully, but these errors were encountered: