]> git.proxmox.com Git - rustc.git/blob - src/test/ui/generic-associated-types/pointer_family.rs
New upstream version 1.55.0+dfsg1
[rustc.git] / src / test / ui / generic-associated-types / pointer_family.rs
1 #![feature(generic_associated_types)]
2
3 // check-pass
4
5 use std::rc::Rc;
6 use std::sync::Arc;
7 use std::ops::Deref;
8
9 trait PointerFamily {
10 type Pointer<T>: Deref<Target = T>;
11 fn new<T>(value: T) -> Self::Pointer<T>;
12 }
13
14 struct ArcFamily;
15
16 impl PointerFamily for ArcFamily {
17 type Pointer<T> = Arc<T>;
18 fn new<T>(value: T) -> Self::Pointer<T> {
19 Arc::new(value)
20 }
21 }
22
23 struct RcFamily;
24
25 impl PointerFamily for RcFamily {
26 type Pointer<T> = Rc<T>;
27 fn new<T>(value: T) -> Self::Pointer<T> {
28 Rc::new(value)
29 }
30 }
31
32 struct Foo<P: PointerFamily> {
33 bar: P::Pointer<String>,
34 }
35
36 fn main() {}