Skip to content

Commit 2ce2469

Browse files
committed
Add dead_code attribute to struct
1 parent 7e42682 commit 2ce2469

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

13_structs.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ As long as all the fields of the struct implement the `Debug` trait, this will w
163163
Let's remove the `impl` block and the `use std::fmt` statement and just add this attribute to our struct:
164164

165165
```rust
166+
#[allow(dead_code)]
166167
#[derive(Debug)]
167168
struct Input {
168169
txid: [u8; 32],
@@ -172,7 +173,8 @@ struct Input {
172173
}
173174
```
174175

175-
And voila! That works now and is much cleaner isn't it?
176+
And voila! That works now and is much cleaner isn't it?
177+
The attribute `#[allow(dead_code)]` is a hint to the compiler that we know we are not using the struct fields right now, but we will in the next section.
176178

177179
Now that we understand a bit more about structs and trait implementations, let's work on displaying this information in a more readable way.
178180
Rather than print out the debugging output, we'll instead **serialize** the data according to a standard JSON format and display that.

0 commit comments

Comments
 (0)