mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-02 07:22:42 +00:00
22 lines
360 B
Rust
22 lines
360 B
Rust
// run-pass
|
|
#![allow(unused_variables)]
|
|
|
|
trait Nat {
|
|
const VALUE: usize;
|
|
}
|
|
|
|
struct Zero;
|
|
struct Succ<N>(#[allow(unused_tuple_struct_fields)] N);
|
|
|
|
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];
|
|
}
|