Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pub struct Rectangle {
- length: u32,
- width: u32,
- }
- impl Rectangle {
- pub fn can_hold(&self, other: &Rectangle) -> bool {
- self.length > other.length && self.width > other.width
- }
- }
- fn adder(x: i32, y: i32) -> i32 {
- return (x + y) as i32;
- }
- #[cfg(test)]
- mod tests {
- use super::*;
- #[test]
- fn larger_can_hold_smaller() {
- let larger = Rectangle {
- length: 8,
- width: 7,
- };
- let smaller = Rectangle {
- length: 5,
- width: 1,
- };
- assert!(larger.can_hold(&smaller));
- }
- #[test]
- fn another_test() {
- assert_eq!(adder(2, 3), 5);
- }
- }
Add Comment
Please, Sign In to add comment