2018-09-06 07:41:12 -05:00
|
|
|
// run-pass
|
2018-09-25 16:51:35 -05:00
|
|
|
#![allow(unused_variables)]
|
2018-09-06 07:41:12 -05:00
|
|
|
|
2017-10-25 02:13:41 -05:00
|
|
|
trait Nat {
|
|
|
|
const VALUE: usize;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Zero;
|
2022-07-25 15:36:03 -05:00
|
|
|
struct Succ<N>(#[allow(unused_tuple_struct_fields)] N);
|
2017-10-25 02:13:41 -05:00
|
|
|
|
|
|
|
impl Nat for Zero {
|
|
|
|
const VALUE: usize = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<N: Nat> Nat for Succ<N> {
|
|
|
|
const VALUE: usize = N::VALUE + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let x: [i32; <Succ<Succ<Succ<Succ<Zero>>>>>::VALUE] = [1, 2, 3, 4];
|
|
|
|
}
|