Skip to content

Commit 91041d4

Browse files
authored
fix: provide examples and clarification to use rust code blocks (#277)
1 parent 9aba2eb commit 91041d4

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

.github/ISSUE_TEMPLATE/CODING-GUIDELINE.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,22 +155,24 @@ body:
155155
attributes:
156156
label: Non-Compliant Example - Code
157157
description: |
158-
Code example showcasing the unintended or consequential behavior. Non-normative.
158+
Code example showcasing the unintended or consequential behavior. Non-normative. Please wrap your code in a fenced code block with the `rust` language specifier.
159159
160160
**Hidden lines:** If your code needs `use` statements, a `fn main()` wrapper, or other boilerplate to compile, but you don't want them shown in the documentation, prefix those lines with `# ` (hash + space). These lines will be compiled but hidden in the rendered docs.
161161
162162
Example with hidden lines:
163-
```
163+
```rust
164164
# use std::mem::MaybeUninit;
165165
# fn main() {
166166
let x: u32 = unsafe { MaybeUninit::uninit().assume_init() }; // UB
167167
# }
168168
```
169169
placeholder: |
170+
```rust
170171
# use std::collections::HashMap;
171172
# fn main() {
172173
let map = HashMap::new();
173174
# }
175+
```
174176
validations:
175177
required: true
176178
- type: textarea
@@ -186,21 +188,23 @@ body:
186188
attributes:
187189
label: Compliant Example - Code
188190
description: |
189-
Code example showcasing we avoid unintended or consequential behavior by following the Coding Guideline.
191+
Code example showcasing we avoid unintended or consequential behavior by following the Coding Guideline. Please wrap your code in a fenced code block with the `rust` language specifier.
190192
191193
**Hidden lines:** If your code needs `use` statements, a `fn main()` wrapper, or other boilerplate to compile, but you don't want them shown in the documentation, prefix those lines with `# ` (hash + space). These lines will be compiled but hidden in the rendered docs.
192194
193195
Example with hidden lines:
194-
```
196+
```rust
195197
# use std::collections::HashMap;
196198
# fn main() {
197199
let mut map = HashMap::new();
198200
map.insert("key", "value"); // Compliant usage
199201
# }
200202
```
201203
placeholder: |
204+
```rust
202205
# fn main() {
203206
let safe_value = 42u32; // Properly initialized
204207
# }
208+
```
205209
validations:
206210
required: true

0 commit comments

Comments
 (0)