Anonymous user
Accumulator factory: Difference between revisions
m
Modfiy rust solution to use impl Trait instead of Box<dyn Trait>
(Added Wren) |
m (Modfiy rust solution to use impl Trait instead of Box<dyn Trait>) |
||
Line 2,843:
Changing "x = foo(1.)" to "x = foo(1)" in the code below should not change the output (it does).
<lang rust>// rustc
use std::ops::Add;
fn foo<Num>(n: Num) ->
where Num: Add<Output=Num> + Copy + 'static {
let mut acc = n;
acc = acc + i;
acc
}
}
|