diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-11-06 19:30:06 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-11-06 19:30:06 +0000 |
commit | 6a759e51608c690b2e1f83090208e301e3a5f475 (patch) | |
tree | fc1ef378430afd0e08de576b84b7208d34dd7a01 /docs/dev/style.md | |
parent | 0d5be44b6e0ccd3e806697dcfc2337a2c0ed5914 (diff) | |
parent | 9b1d4cc8abdd756f6a46e220a278c012846bb56a (diff) |
Merge #6483
6483: don\t indent tests r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'docs/dev/style.md')
-rw-r--r-- | docs/dev/style.md | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/docs/dev/style.md b/docs/dev/style.md index 8d57fc049..1a952197f 100644 --- a/docs/dev/style.md +++ b/docs/dev/style.md | |||
@@ -89,6 +89,32 @@ There are many benefits to this: | |||
89 | It also makes sense to format snippets more compactly (for example, by placing enum definitions like `enum E { Foo, Bar }` on a single line), | 89 | It also makes sense to format snippets more compactly (for example, by placing enum definitions like `enum E { Foo, Bar }` on a single line), |
90 | as long as they are still readable. | 90 | as long as they are still readable. |
91 | 91 | ||
92 | When using multiline fixtures, use unindented raw string literals: | ||
93 | |||
94 | ```rust | ||
95 | #[test] | ||
96 | fn inline_field_shorthand() { | ||
97 | check_assist( | ||
98 | inline_local_variable, | ||
99 | r" | ||
100 | struct S { foo: i32} | ||
101 | fn main() { | ||
102 | let <|>foo = 92; | ||
103 | S { foo } | ||
104 | } | ||
105 | ", | ||
106 | r" | ||
107 | struct S { foo: i32} | ||
108 | fn main() { | ||
109 | S { foo: 92 } | ||
110 | } | ||
111 | ", | ||
112 | ); | ||
113 | } | ||
114 | ``` | ||
115 | |||
116 | That way, you can use your editor's "number of selected characters" feature to correlate offsets with test's source code. | ||
117 | |||
92 | ## Preconditions | 118 | ## Preconditions |
93 | 119 | ||
94 | Express function preconditions in types and force the caller to provide them (rather than checking in callee): | 120 | Express function preconditions in types and force the caller to provide them (rather than checking in callee): |