2019-05-30 17:44:28 -05:00
|
|
|
// run-pass
|
2020-08-09 01:19:57 -05:00
|
|
|
// revisions: full min
|
|
|
|
|
|
|
|
#![cfg_attr(full, feature(const_generics))]
|
|
|
|
#![cfg_attr(full, allow(incomplete_features))]
|
|
|
|
#![cfg_attr(min, feature(min_const_generics))]
|
2019-05-30 17:44:28 -05:00
|
|
|
|
|
|
|
|
|
|
|
use std::ops::AddAssign;
|
|
|
|
|
|
|
|
fn inc<T: AddAssign + Clone, const N: usize>(v: &mut [T; N]) -> &mut [T; N] {
|
|
|
|
for x in v.iter_mut() {
|
|
|
|
*x += x.clone();
|
|
|
|
}
|
|
|
|
v
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut v = [1, 2, 3];
|
|
|
|
inc(&mut v);
|
|
|
|
assert_eq!(v, [2, 4, 6]);
|
|
|
|
}
|