mirror of
https://github.com/rust-lang/rust
synced 2024-09-05 16:57:03 +00:00
33 lines
492 B
Rust
33 lines
492 B
Rust
//@ check-pass
|
|
|
|
#![feature(generic_const_exprs)]
|
|
#![allow(incomplete_features)]
|
|
|
|
pub trait Trait{
|
|
type R;
|
|
fn func(self)->Self::R;
|
|
}
|
|
|
|
pub struct TraitImpl<const N:usize>(pub i32);
|
|
|
|
impl<const N:usize> Trait for TraitImpl<N>
|
|
where [();N/2]:,
|
|
{
|
|
type R = Self;
|
|
fn func(self)->Self::R {
|
|
self
|
|
}
|
|
}
|
|
|
|
fn sample<P,Convert>(p:P,f:Convert) -> i32
|
|
where
|
|
P:Trait,Convert:Fn(P::R)->i32
|
|
{
|
|
f(p.func())
|
|
}
|
|
|
|
fn main() {
|
|
let t = TraitImpl::<10>(4);
|
|
sample(t,|x|x.0);
|
|
}
|