blob: 0c2473fae5dc899f57261a84b8093d90acd4d71a [file] [log] [blame]
David Tolnay55337722016-09-11 12:58:56 -07001use Ident;
2
3pub trait ToIdent {
4 fn to_ident(&self) -> Ident;
5}
6
7impl ToIdent for Ident {
8 fn to_ident(&self) -> Ident {
9 self.clone()
10 }
11}
12
13impl<'a> ToIdent for &'a str {
14 fn to_ident(&self) -> Ident {
15 (**self).into()
16 }
17}
18
19impl ToIdent for String {
20 fn to_ident(&self) -> Ident {
21 self.clone().into()
22 }
23}
24
David Tolnaydaaf7742016-10-03 11:11:43 -070025impl<'a, T> ToIdent for &'a T
26 where T: ToIdent
27{
David Tolnay55337722016-09-11 12:58:56 -070028 fn to_ident(&self) -> Ident {
29 (**self).to_ident()
30 }
31}
32
David Tolnaydaaf7742016-10-03 11:11:43 -070033impl<'a, T> ToIdent for &'a mut T
34 where T: ToIdent
35{
David Tolnay55337722016-09-11 12:58:56 -070036 fn to_ident(&self) -> Ident {
37 (**self).to_ident()
38 }
39}