blob: acdc348a385a310d7ed79bee44f13d0bcd63eb0f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
// build-pass
#![allow(incomplete_features)]
#![feature(generic_const_exprs)]
trait TraitOne {
const MY_NUM: usize;
type MyErr: std::fmt::Debug;
fn do_one_stuff(arr: [u8; Self::MY_NUM]) -> Result<(), Self::MyErr>;
}
trait TraitTwo {
fn do_two_stuff();
}
impl<O: TraitOne> TraitTwo for O
where
[(); Self::MY_NUM]:,
{
fn do_two_stuff() {
O::do_one_stuff([5; Self::MY_NUM]).unwrap()
}
}
struct Blargotron;
#[derive(Debug)]
struct ErrTy<const N: usize>([(); N]);
impl TraitOne for Blargotron {
const MY_NUM: usize = 3;
type MyErr = ErrTy<{ Self::MY_NUM }>;
fn do_one_stuff(_arr: [u8; Self::MY_NUM]) -> Result<(), Self::MyErr> {
Ok(())
}
}
fn main() {
Blargotron::do_two_stuff();
}
|