aboutsummaryrefslogtreecommitdiff
path: root/docs/user
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-11-15 07:01:19 +0000
committerGitHub <[email protected]>2019-11-15 07:01:19 +0000
commit3ad11973ac7596323f085a9fcb9530e47f021c41 (patch)
tree15d397d8732ddd5511f85f45689fb5b32441e36f /docs/user
parenta6d080608db1bcc2a2f8fc586d8a5d3c85e50763 (diff)
parentcbc6f94573d7f4601b739e001de5d5f71ec9b552 (diff)
Merge #2165
2165: ra_assists: Add add_new assist r=matklad a=rep-nop 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. Not marking this as closing #1644 since there's a part 2 of adding autocompletion for when someone starts typing `[pub ]fn new(...` Co-authored-by: Wesley Norris <[email protected]>
Diffstat (limited to 'docs/user')
-rw-r--r--docs/user/assists.md21
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;
150fn process(map: HashMap<String, String>) {} 150fn process(map: HashMap<String, String>) {}
151``` 151```
152 152
153## `add_new`
154
155Adds a new inherent impl for a type.
156
157```rust
158// BEFORE
159struct Ctx<T: Clone> {
160 data: T,┃
161}
162
163// AFTER
164struct Ctx<T: Clone> {
165 data: T,
166}
167
168impl<T: Clone> Ctx<T> {
169 fn new(data: T) -> Self { Self { data } }
170}
171
172```
173
153## `apply_demorgan` 174## `apply_demorgan`
154 175
155Apply [De Morgan's law](https://en.wikipedia.org/wiki/De_Morgan%27s_laws). 176Apply [De Morgan's law](https://en.wikipedia.org/wiki/De_Morgan%27s_laws).