pedrov/
lib.rs

1// Documentation comments are declared with three `/`s.
2
3// It generates HTML and supports Markdown.
4// This can be done and opened with `cargo doc --open`. It generates this for all crates in the
5// package, internal and external.
6
7// Usually, they contain:
8// - Description: Short summary.
9// - Examples: Important, useful examples.
10// - Panics: Situation where the code panics.
11// - Errors: About the E in Result<T, E>.
12// - Safety: If the function uses unsafe, why and which variants are expected.
13
14// Example code blocks in the comments are also ran with `cargo test`.
15
16// Documentation comments can apply to the item that contains the comment, using //!
17
18//! # Pedrov
19//!
20//! `pedrov` is a collection of utilities to make performing certain
21//! calculations more convenient.
22
23/// Adds one to the number given.
24///
25/// # Examples
26///
27/// ```
28/// let arg = 5;
29/// let answer = pedrov::add_one(arg);
30///
31/// assert_eq!(6, answer);
32/// ```
33pub fn add_one(x: i32) -> i32 {
34    x + 1
35}
36
37#[cfg(test)]
38mod tests {
39    use super::*;
40
41    #[test]
42    fn test_add_one() {
43        assert_eq!(add_one(1), 2);
44    }
45}