We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent eee160c commit a2b1827Copy full SHA for a2b1827
src/test/ui/const-generics/type-dependent/issue-71348.rs
@@ -0,0 +1,35 @@
1
+// run-pass
2
+#![feature(const_generics)]
3
+#![allow(incomplete_features)]
4
+
5
+struct Foo {
6
+ i: i32,
7
+}
8
9
+trait Get<'a, const N: &'static str> {
10
+ type Target: 'a;
11
12
+ fn get(&'a self) -> &'a Self::Target;
13
14
15
+impl Foo {
16
+ fn ask<'a, const N: &'static str>(&'a self) -> &'a <Self as Get<N>>::Target
17
+ where
18
+ Self: Get<'a, N>,
19
+ {
20
+ self.get()
21
+ }
22
23
24
+impl<'a> Get<'a, "int"> for Foo {
25
+ type Target = i32;
26
27
+ fn get(&'a self) -> &'a Self::Target {
28
+ &self.i
29
30
31
32
+fn main() {
33
+ let foo = Foo { i: 123 };
34
+ assert_eq!(foo.ask::<"int">(), &123);
35
0 commit comments