]> git.lizzy.rs Git - rust.git/blob - src/test/ui-fulldeps/issue-24972.rs
Rollup merge of #93515 - dtolnay:convenience, r=davidtwco
[rust.git] / src / test / ui-fulldeps / issue-24972.rs
1 // run-pass
2
3 #![allow(dead_code)]
4 #![feature(rustc_private)]
5
6 extern crate rustc_serialize;
7
8 use rustc_serialize::{json, Decodable, Encodable};
9 use std::fmt::Display;
10
11 pub trait Entity: Decodable<json::Decoder> + for<'a> Encodable<json::Encoder<'a>> + Sized {
12     type Key: Clone
13         + Decodable<json::Decoder>
14         + for<'a> Encodable<json::Encoder<'a>>
15         + ToString
16         + Display
17         + Eq
18         + Ord
19         + Sized;
20
21     fn id(&self) -> Self::Key;
22
23     fn find_by_id(id: Self::Key) -> Option<Self>;
24 }
25
26 pub struct DbRef<E: Entity> {
27     pub id: E::Key,
28 }
29
30 impl<E> DbRef<E>
31 where
32     E: Entity,
33 {
34     fn get(self) -> Option<E> {
35         E::find_by_id(self.id)
36     }
37 }
38
39 fn main() {}