• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

styles/H03-May-2022-129

Clone.mdH A D23-Jan-20211.6 KiB3929

Debug.mdH A D23-Jan-20213.9 KiB153125

Default.mdH A D23-Jan-20212.5 KiB10784

Hash.mdH A D23-Jan-20212.1 KiB8467

README.mdH A D23-Jan-20212 KiB12694

SUMMARY.mdH A D23-Jan-20211.2 KiB2624

cmp.mdH A D23-Jan-20213.7 KiB12396

custom.cssH A D23-Jan-2021369 2419

debug-transparent-orig.rsH A D23-Jan-2021185 87

debug-transparent.rsH A D23-Jan-2021144 55

default-enum-orig.rsH A D23-Jan-2021307 2015

default-enum.rsH A D23-Jan-2021224 119

default-value-orig.rsH A D23-Jan-2021703 2726

default-value.rsH A D23-Jan-2021532 1818

eq-ignore-orig.rsH A D23-Jan-20211.1 KiB4027

eq-ignore.rsH A D23-Jan-2021784 2615

README.md

1# Derivative
2
3This crate provides a set of alternative `#[derive]` attributes for Rust.
4
5## Examples
6
7*derivative* uses attributes to make it possible to derive more implementations
8than the built-in `derive(Trait)`. Here are a few examples of stuffs you cannot
9just `derive`.
10
11You can derive `Default` on enumerations:
12
13<table>
14<tr>
15<th>
16
17With *derivative*
18</th>
19<th>
20
21[Original][default-value-source]
22</th>
23</tr>
24<tr>
25</tr>
26<tr class="readme-example">
27<td>
28
29{{#playground default-enum.rs}}
30</td>
31<td>
32
33{{#playground default-enum-orig.rs}}
34</td>
35</tr>
36</table>
37
38You can use different default values for some fields:
39
40<table>
41<tr>
42<th>
43
44With *derivative*
45</th>
46<th>
47
48[Original][default-value-source]
49</th>
50</tr>
51<tr>
52</tr>
53<tr class="readme-example">
54<td>
55
56{{#playground default-value.rs}}
57</td>
58<td>
59
60{{#playground default-value-orig.rs}}
61</td>
62</tr>
63</table>
64
65
66Want a transparent `Debug` implementation for your wrapper? We got that:
67
68<table>
69<tr>
70<th>
71
72With *derivative*
73</th>
74<th>
75
76[Original][transparent-source]
77</th>
78</tr>
79<tr>
80</tr>
81<tr class="readme-example">
82<td>
83
84{{#playground debug-transparent.rs}}
85</td>
86<td>
87
88{{#playground debug-transparent-orig.rs}}
89</td>
90</tr>
91</table>
92
93
94Need to ignore a field? We got that too:
95
96<table>
97<tr>
98<th>
99
100With *derivative*
101</th>
102<th>
103
104[Original][eq-ignore-source]
105</th>
106</tr>
107<tr>
108</tr>
109<tr class="readme-example">
110<td>
111
112{{#playground eq-ignore.rs}}
113</td>
114<td>
115
116{{#playground eq-ignore-orig.rs}}
117</td>
118</tr>
119</table>
120
121
122[default-value-source]: https://github.com/rust-lang-nursery/regex/blob/3cfef1e79d135a3e8a670aff53e7fabef453a3e1/src/re_builder.rs#L12-L39
123[default-enum-source]: https://github.com/rust-lang/rust/blob/16eeeac783d2ede28e09f2a433c612dea309fe33/src/libcore/option.rs#L714-L718
124[transparent-source]: https://github.com/rust-lang/rust/blob/5457c35ece57bbc4a65baff239a02d6abb81c8a2/src/libcore/num/mod.rs#L46-L54
125[eq-ignore-source]: https://github.com/steveklabnik/semver/blob/baa0fbb57c80a7fb344fbeedac24a28439ddf5b5/src/version.rs#L196-L205
126