This commit is contained in:
Jasper Ras 2026-02-21 20:04:40 +01:00
parent 2f6caa57f0
commit 7a0faffd01
3 changed files with 44 additions and 0 deletions

7
ch11/adder/Cargo.lock generated Normal file
View file

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "adder"
version = "0.1.0"

6
ch11/adder/Cargo.toml Normal file
View file

@ -0,0 +1,6 @@
[package]
name = "adder"
version = "0.1.0"
edition = "2024"
[dependencies]

31
ch11/adder/src/lib.rs Normal file
View file

@ -0,0 +1,31 @@
pub fn add(left: u64, right: u64) -> u64 {
left + right
}
#[derive(Debug)]
struct Rectangle {
width: u32,
height: u32,
}
impl Rectangle {
fn can_hold(&self, other: &Rectangle) -> bool {
self.width >= other.width && self.height >= other.height
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn explore() {
let result = add(2, 2);
assert_eq!(result, 4);
}
#[test]
fn another() {
panic!("Fail!")
}
}