diff options
author | Wesley Norris <[email protected]> | 2019-11-09 15:56:36 +0000 |
---|---|---|
committer | Wesley Norris <[email protected]> | 2019-11-09 15:56:36 +0000 |
commit | cbc6f94573d7f4601b739e001de5d5f71ec9b552 (patch) | |
tree | ee481bcf679e739dfea13ec36b16fb593607e43a /docs | |
parent | 9d786ea221b27fbdf7c7f7beea0290db448e0611 (diff) |
Add add_new assist
Adds a new assist to autogenerate a new fn based on the selected struct,
excluding tuple structs and unions. The fn will inherit the same
visibility as the struct and the assist will attempt to reuse any
existing impl blocks that exist at the same level of struct.
Diffstat (limited to 'docs')
-rw-r--r-- | docs/user/assists.md | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/docs/user/assists.md b/docs/user/assists.md index 303353e74..8da7578e2 100644 --- a/docs/user/assists.md +++ b/docs/user/assists.md | |||
@@ -150,6 +150,27 @@ use std::collections::HashMap; | |||
150 | fn process(map: HashMap<String, String>) {} | 150 | fn process(map: HashMap<String, String>) {} |
151 | ``` | 151 | ``` |
152 | 152 | ||
153 | ## `add_new` | ||
154 | |||
155 | Adds a new inherent impl for a type. | ||
156 | |||
157 | ```rust | ||
158 | // BEFORE | ||
159 | struct Ctx<T: Clone> { | ||
160 | data: T,┃ | ||
161 | } | ||
162 | |||
163 | // AFTER | ||
164 | struct Ctx<T: Clone> { | ||
165 | data: T, | ||
166 | } | ||
167 | |||
168 | impl<T: Clone> Ctx<T> { | ||
169 | fn new(data: T) -> Self { Self { data } } | ||
170 | } | ||
171 | |||
172 | ``` | ||
173 | |||
153 | ## `apply_demorgan` | 174 | ## `apply_demorgan` |
154 | 175 | ||
155 | Apply [De Morgan's law](https://en.wikipedia.org/wiki/De_Morgan%27s_laws). | 176 | Apply [De Morgan's law](https://en.wikipedia.org/wiki/De_Morgan%27s_laws). |