Skip to content

Instantly share code, notes, and snippets.

@Kerollmops
Last active November 10, 2017 14:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kerollmops/4b17eddfdaadfe8e43c912cd029fd5fa to your computer and use it in GitHub Desktop.
Save Kerollmops/4b17eddfdaadfe8e43c912cd029fd5fa to your computer and use it in GitHub Desktop.
Little hack to display default values in the doc. (don't forget to `cargo test --doc`)
#[derive(Debug, PartialEq, Eq)]
pub struct Aaa {
pub field1: usize,
pub field2: i32,
}
impl Default for Aaa {
/// ```
/// # use aaa::Aaa;
/// # let a =
/// Aaa {
/// field1: 3,
/// field2: 5,
/// }
/// # ;
/// # assert_eq!(a, Aaa::default());
/// ```
fn default() -> Self {
Self {
field1: 3,
field2: 5,
}
}
}
@Kerollmops
Copy link
Author

capture d ecran 2017-11-10 a 00 36 18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment