pub trait PatchHugrMut: PatchVerification {
type Outcome;
const UNCHANGED_ON_FAILURE: bool;
// Required method
fn apply_hugr_mut(
self,
h: &mut impl HugrMut<Node = Self::Node>,
) -> Result<Self::Outcome, Self::Error>;
}Expand description
A patch that can be applied to any HugrMut.
This trait is a generalisation of Patch in that it guarantees that
the patch can be applied to any type implementing HugrMut.
§When to use
Prefer using the more general Patch trait in bounds where the
type H is known. Resort to this trait if patches must be applicable to
any HugrMut instance.
§When to implement
Always implement this trait when possible, to define how a patch is applied
to any type implementing HugrMut. A blanket implementation ensures that
any type implementing this trait also implements Patch.
Required Associated Constants§
Sourceconst UNCHANGED_ON_FAILURE: bool
const UNCHANGED_ON_FAILURE: bool
If true, PatchHugrMut::apply_hugr_mut’s of this rewrite guarantee
that they do not mutate the Hugr when they return an Err. If false,
there is no guarantee; the Hugr should be assumed invalid when Err is
returned.
Required Associated Types§
Required Methods§
Sourcefn apply_hugr_mut(
self,
h: &mut impl HugrMut<Node = Self::Node>,
) -> Result<Self::Outcome, Self::Error>
fn apply_hugr_mut( self, h: &mut impl HugrMut<Node = Self::Node>, ) -> Result<Self::Outcome, Self::Error>
Mutate the specified Hugr, or fail with an error.
Returns PatchHugrMut::Outcome if successful. If
PatchHugrMut::UNCHANGED_ON_FAILURE is true, then h must be
unchanged if Err is returned. See also PatchVerification::verify
§Panics
May panic if-and-only-if h would have failed
Hugr::validate; that is, implementations may
begin with assert!(h.validate()), with debug_assert!(h.validate())
being preferred.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.