Last active
June 20, 2017 18:23
-
-
Save dobkeratops/a68a600884ad5ac9219966402d814d36 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This compiles, but didn't need lifetime annotations. | |
// what does this do differently compared to the version using operators? | |
pub trait MulRef<B> { | |
type Output; | |
fn mul_ref(&self,&B)->Self::Output; | |
} | |
pub trait AddRef<B> { | |
type Output; | |
fn add_ref(&self,&B)->Self::Output; | |
} | |
pub fn madd_r1<A,B,C,P>(a:&A,b:&B,c:&C)->A where | |
B:MulRef<C,Output=P>, | |
A:AddRef<P,Output=A>, | |
{ | |
let p=b.mul_ref(c); | |
a.add_ref(&p) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment