]> git.lizzy.rs Git - rust.git/blob - src/test/ui/rfc-2632-const-trait-impl/const-closures.rs
Auto merge of #105651 - tgross35:once-cell-inline, r=m-ou-se
[rust.git] / src / test / ui / rfc-2632-const-trait-impl / const-closures.rs
1 // run-pass
2
3 #![feature(const_trait_impl)]
4
5 const fn answer_p1<F>(f: &F) -> u8
6     where
7         F: ~const FnOnce() -> u8,
8         F: ~const FnMut() -> u8,
9         F: ~const Fn() -> u8,
10 {
11     f() * 7
12 }
13
14 const fn three() -> u8 {
15     3
16 }
17
18 const fn answer_p2() -> u8 {
19     answer_p1(&three)
20 }
21
22 const fn answer<F: ~const Fn() -> u8>(f: &F) -> u8 {
23     f() + f()
24 }
25
26 const ANSWER: u8 = answer(&answer_p2);
27
28 fn main() {
29     assert_eq!(ANSWER, 42)
30 }