Even or odd and factorial
Pre-release
Pre-release
In this session I learned:
- how to structure a rust project and use
mod.rsfiles - how to write functions and return values
- I got a lot of warnings from dead code/ unused imports, so I learned how to disable them
- I learned how to work with
Result- learned how to do error handling
unwrap()- to create a string from "text" by using
.to_string() - How to use
Ok()andErr - I used the ? operator for concise error handling
- How to do unit testing
- set up structure for unit tests
#[cfg(test)]and#[test]to execute tests- had some problems when trying to import from my code since I use this code structure:

- But was eventually able to fix it with
lib.rsfile -> also had to makemods andfns public - Learned about using public scopes
pub(scope) - Learned to use
assert_eq!andassert!
... by implementing a method that checks if an integer is even or odd and a method that calculates the factorial of a non-negative integer smaller than 21 (i64 bounds)
Next things to learn:
- documentation: method/ class comments
- structs
- What the
!means exactly - ...?