gabadder/lib.rs
1pub mod mathlib {
2 /// Ajoute 1 au nombre passé
3 ///
4 /// # exemple
5 ///
6 /// ```
7 /// use gabadder::mathlib::ajouter_un;
8 /// assert_eq!(ajouter_un(3), 4);
9 /// ```
10 ///
11 pub fn ajouter_un(x: i32) -> i32 {
12 x + 1
13 }
14
15 /// division de x et y
16 ///
17 /// # exemple
18 ///
19 /// ```
20 /// use gabadder::mathlib::diviser;
21 /// assert_eq!(diviser(3.0, 2.0), 1.5);
22 /// ```
23 ///
24 pub fn diviser(x: f64, y: f64) -> f64 {
25 x / y
26 }
27
28 /// Retranche 1 au nombre passé
29 ///
30
31 ///
32 fn retrancher_un(x: i32) -> i32 {
33 x - 1
34 }
35}
36
37#[cfg(test)]
38mod tests {
39 use crate::mathlib::{ajouter_un, diviser};
40
41 #[test]
42 fn it_works() {
43 assert_eq!(ajouter_un(3), 4);
44 }
45
46 #[test]
47 fn it_divide() {
48 assert_eq!(diviser(3.0, 2.0), 1.5);
49 }
50}