Mercurial > crates > nonstick
comparison src/items.rs @ 12:30831c70e5c0
Remove PhantomData usage.
PhantomData is used through the library to substitute associated
constants (to types). However, calling
`PamItem::item_type(PhantomData<T>)` can easily be substituted by
calling `T::item_type()`, getting rid of the need for PhantomData.
author | Marc Brinkmann <git@marcbrinkmann.de> |
---|---|
date | Sun, 26 Feb 2017 12:12:36 +0100 |
parents | 827faa554528 |
children |
comparison
equal
deleted
inserted
replaced
11:827faa554528 | 12:30831c70e5c0 |
---|---|
1 use std::marker::PhantomData; | |
2 use constants::{PamItemType, PAM_SERVICE, PAM_USER, PAM_USER_PROMPT, PAM_TTY, PAM_RUSER, PAM_RHOST, | 1 use constants::{PamItemType, PAM_SERVICE, PAM_USER, PAM_USER_PROMPT, PAM_TTY, PAM_RUSER, PAM_RHOST, |
3 PAM_AUTHTOK, PAM_OLDAUTHTOK}; | 2 PAM_AUTHTOK, PAM_OLDAUTHTOK}; |
4 use module::PamItem; | 3 use module::PamItem; |
5 pub use conv::PamConv; | 4 pub use conv::PamConv; |
6 | 5 |
7 | 6 |
8 pub struct PamService {} | 7 pub struct PamService {} |
9 | 8 |
10 impl PamItem for PamService { | 9 impl PamItem for PamService { |
11 fn item_type(_: PhantomData<Self>) -> PamItemType { | 10 fn item_type() -> PamItemType { |
12 PAM_SERVICE | 11 PAM_SERVICE |
13 } | 12 } |
14 } | 13 } |
15 | 14 |
16 pub struct PamUser {} | 15 pub struct PamUser {} |
17 | 16 |
18 impl PamItem for PamUser { | 17 impl PamItem for PamUser { |
19 fn item_type(_: PhantomData<Self>) -> PamItemType { | 18 fn item_type() -> PamItemType { |
20 PAM_USER | 19 PAM_USER |
21 } | 20 } |
22 } | 21 } |
23 | 22 |
24 pub struct PamUserPrompt {} | 23 pub struct PamUserPrompt {} |
25 | 24 |
26 impl PamItem for PamUserPrompt { | 25 impl PamItem for PamUserPrompt { |
27 fn item_type(_: PhantomData<Self>) -> PamItemType { | 26 fn item_type() -> PamItemType { |
28 PAM_USER_PROMPT | 27 PAM_USER_PROMPT |
29 } | 28 } |
30 } | 29 } |
31 | 30 |
32 pub struct PamTty {} | 31 pub struct PamTty {} |
33 | 32 |
34 impl PamItem for PamTty { | 33 impl PamItem for PamTty { |
35 fn item_type(_: PhantomData<Self>) -> PamItemType { | 34 fn item_type() -> PamItemType { |
36 PAM_TTY | 35 PAM_TTY |
37 } | 36 } |
38 } | 37 } |
39 | 38 |
40 pub struct PamRUser {} | 39 pub struct PamRUser {} |
41 | 40 |
42 impl PamItem for PamRUser { | 41 impl PamItem for PamRUser { |
43 fn item_type(_: PhantomData<Self>) -> PamItemType { | 42 fn item_type() -> PamItemType { |
44 PAM_RUSER | 43 PAM_RUSER |
45 } | 44 } |
46 } | 45 } |
47 | 46 |
48 pub struct PamRHost {} | 47 pub struct PamRHost {} |
49 | 48 |
50 impl PamItem for PamRHost { | 49 impl PamItem for PamRHost { |
51 fn item_type(_: PhantomData<Self>) -> PamItemType { | 50 fn item_type() -> PamItemType { |
52 PAM_RHOST | 51 PAM_RHOST |
53 } | 52 } |
54 } | 53 } |
55 | 54 |
56 pub struct PamAuthTok {} | 55 pub struct PamAuthTok {} |
57 | 56 |
58 impl PamItem for PamAuthTok { | 57 impl PamItem for PamAuthTok { |
59 fn item_type(_: PhantomData<Self>) -> PamItemType { | 58 fn item_type() -> PamItemType { |
60 PAM_AUTHTOK | 59 PAM_AUTHTOK |
61 } | 60 } |
62 } | 61 } |
63 | 62 |
64 pub struct PamOldAuthTok {} | 63 pub struct PamOldAuthTok {} |
65 | 64 |
66 impl PamItem for PamOldAuthTok { | 65 impl PamItem for PamOldAuthTok { |
67 fn item_type(_: PhantomData<Self>) -> PamItemType { | 66 fn item_type() -> PamItemType { |
68 PAM_OLDAUTHTOK | 67 PAM_OLDAUTHTOK |
69 } | 68 } |
70 } | 69 } |