]>
Commit | Line | Data |
---|---|---|
74b04a01 | 1 | #![feature(const_trait_impl)] |
74b04a01 | 2 | |
2b03887a | 3 | #[const_trait] |
74b04a01 XL |
4 | pub trait Plus { |
5 | fn plus(self, rhs: Self) -> Self; | |
6 | } | |
7 | ||
8 | impl const Plus for i32 { | |
9 | fn plus(self, rhs: Self) -> Self { | |
10 | self + rhs | |
11 | } | |
12 | } | |
13 | ||
14 | impl Plus for u32 { | |
15 | fn plus(self, rhs: Self) -> Self { | |
16 | self + rhs | |
17 | } | |
18 | } | |
19 | ||
20 | pub const fn add_i32(a: i32, b: i32) -> i32 { | |
21 | a.plus(b) // ok | |
22 | } | |
23 | ||
24 | pub const fn add_u32(a: u32, b: u32) -> u32 { | |
25 | a.plus(b) | |
5099ac24 | 26 | //~^ ERROR the trait bound |
74b04a01 XL |
27 | } |
28 | ||
29 | fn main() {} |