Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
When documenting a struct with attributes, where does the docstring go? Before or after the attribute(s)? Option 1: /// Does it go here? #[derive(Deserialize, Debug)] pub struct Metadata { ...
#4: Post edited
Proper location of docstring on struct with attributes
- When documenting a struct with attributes, where does the docstring go? Before or after the attribute(s)?
- Option 1:
```- /// Does it go here?
- #[derive(Deserialize, Debug)]
- pub struct Metadata {
- pub version: f32,
- pub contributors: Vec<String>
- }
- ```
- Option 2:
```- #[derive(Deserialize, Debug)]
- /// Does it go here?
- pub struct Metadata {
- pub version: f32,
- pub contributors: Vec<String>
- }
- ```
- Option 3 (presumably wrong but adding just in case):
```- #[derive(Deserialize, Debug)]
- pub struct Metadata {
- /// Does it go here? (I assume this would document `version`,
- /// not the struct)
- pub version: f32,
- pub contributors: Vec<String>
}```
- When documenting a struct with attributes, where does the docstring go? Before or after the attribute(s)?
- Option 1:
- ```rust
- /// Does it go here?
- #[derive(Deserialize, Debug)]
- pub struct Metadata {
- pub version: f32,
- pub contributors: Vec<String>
- }
- ```
- Option 2:
- ```rust
- #[derive(Deserialize, Debug)]
- /// Does it go here?
- pub struct Metadata {
- pub version: f32,
- pub contributors: Vec<String>
- }
- ```
- Option 3 (presumably wrong but adding just in case):
- ```rust
- #[derive(Deserialize, Debug)]
- pub struct Metadata {
- /// Does it go here? (I assume this would document `version`,
- /// not the struct)
- pub version: f32,
- pub contributors: Vec<String>
- }
- ```
#3: Post edited
- When documenting a struct with attributes, where does the docstring go? Before or after the attribute(s)?
- Option 1:
- ```
- /// Does it go here?
- #[derive(Deserialize, Debug)]
- pub struct Metadata {
- pub version: f32,
- pub contributors: Vec<String>
- }
- ```
- Option 2:
- ```
- #[derive(Deserialize, Debug)]
- /// Does it go here?
- pub struct Metadata {
- pub version: f32,
- pub contributors: Vec<String>
- }
- ```
Option 3:- ```
- #[derive(Deserialize, Debug)]
- pub struct Metadata {
- /// Does it go here? (I assume this would document `version`,
- /// not the struct)
- pub version: f32,
- pub contributors: Vec<String>
- }```
- When documenting a struct with attributes, where does the docstring go? Before or after the attribute(s)?
- Option 1:
- ```
- /// Does it go here?
- #[derive(Deserialize, Debug)]
- pub struct Metadata {
- pub version: f32,
- pub contributors: Vec<String>
- }
- ```
- Option 2:
- ```
- #[derive(Deserialize, Debug)]
- /// Does it go here?
- pub struct Metadata {
- pub version: f32,
- pub contributors: Vec<String>
- }
- ```
- Option 3 (presumably wrong but adding just in case):
- ```
- #[derive(Deserialize, Debug)]
- pub struct Metadata {
- /// Does it go here? (I assume this would document `version`,
- /// not the struct)
- pub version: f32,
- pub contributors: Vec<String>
- }```
#2: Post edited
- When documenting a struct with attributes, where does the docstring go? Before or after the attribute(s)?
- Option 1:
- ```
- /// Does it go here?
- #[derive(Deserialize, Debug)]
- pub struct Metadata {
- pub version: f32,
- pub contributors: Vec<String>
}```- Option 2:
- ```
- #[derive(Deserialize, Debug)]
- /// Does it go here?
- pub struct Metadata {
- pub version: f32,
- pub contributors: Vec<String>
}```- Option 3:
- ```
- #[derive(Deserialize, Debug)]
- pub struct Metadata {
- /// Does it go here? (I assume this would document `version`,
- /// not the struct)
- pub version: f32,
- pub contributors: Vec<String>
- }```
- When documenting a struct with attributes, where does the docstring go? Before or after the attribute(s)?
- Option 1:
- ```
- /// Does it go here?
- #[derive(Deserialize, Debug)]
- pub struct Metadata {
- pub version: f32,
- pub contributors: Vec<String>
- }
- ```
- Option 2:
- ```
- #[derive(Deserialize, Debug)]
- /// Does it go here?
- pub struct Metadata {
- pub version: f32,
- pub contributors: Vec<String>
- }
- ```
- Option 3:
- ```
- #[derive(Deserialize, Debug)]
- pub struct Metadata {
- /// Does it go here? (I assume this would document `version`,
- /// not the struct)
- pub version: f32,
- pub contributors: Vec<String>
- }```
#1: Initial revision
Proper location of docstring on struct with attributes
When documenting a struct with attributes, where does the docstring go? Before or after the attribute(s)? Option 1: ``` /// Does it go here? #[derive(Deserialize, Debug)] pub struct Metadata { pub version: f32, pub contributors: Vec<String> }``` Option 2: ``` #[derive(Deserialize, Debug)] /// Does it go here? pub struct Metadata { pub version: f32, pub contributors: Vec<String> }``` Option 3: ``` #[derive(Deserialize, Debug)] pub struct Metadata { /// Does it go here? (I assume this would document `version`, /// not the struct) pub version: f32, pub contributors: Vec<String> }```