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