Guest User

Untitled

a guest
May 25th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. pub struct Rectangle {
  2. length: u32,
  3. width: u32,
  4. }
  5.  
  6. impl Rectangle {
  7. pub fn can_hold(&self, other: &Rectangle) -> bool {
  8. self.length > other.length && self.width > other.width
  9. }
  10. }
  11.  
  12. fn adder(x: i32, y: i32) -> i32 {
  13. return (x + y) as i32;
  14. }
  15.  
  16. #[cfg(test)]
  17. mod tests {
  18. use super::*;
  19.  
  20. #[test]
  21. fn larger_can_hold_smaller() {
  22. let larger = Rectangle {
  23. length: 8,
  24. width: 7,
  25. };
  26. let smaller = Rectangle {
  27. length: 5,
  28. width: 1,
  29. };
  30.  
  31. assert!(larger.can_hold(&smaller));
  32. }
  33.  
  34. #[test]
  35. fn another_test() {
  36. assert_eq!(adder(2, 3), 5);
  37. }
  38. }
Add Comment
Please, Sign In to add comment