pub trait FieldRef<Deref>:
PartialEq<Self>
+ Neg<Output = Deref>
+ Add<Deref, Output = Deref>
+ Add<Output = Deref>
+ Sub<Deref, Output = Deref>
+ Sub<Output = Deref>
+ Mul<Deref, Output = Deref>
+ Mul<Output = Deref>
+ Div<Deref, Output = Deref>
+ Div<Output = Deref>
+ Copy
+ Clone
+ Display
+ Debug
+ Sized { }Expand description
A reference to a variable that is in a Field.
§On writing this down less often
Generic code needs F: Field, for<'r> &'r F: FieldRef<F>, and the second half is the awkward
one. Moving it onto the definition of Field, as trait Field where for<'r> &'r Self: FieldRef<Self>, does not help and makes things worse: a where clause on a type that is not
Self is a requirement on implementors, not something a F: Field bound implies, so every
caller still has to discharge it, and now has to do so even when it uses no reference
operations at all.
What does work is not having a reference type to bound. AbsorbAll takes
every operand by reference already, so F: AbsorbAll<F> is a single bound with no higher
ranked part and gives the same arithmetic through methods rather than operators. This trait
stays for code written against the operators.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".