summaryrefslogtreecommitdiff
path: root/ex4_9
diff options
context:
space:
mode:
Diffstat (limited to 'ex4_9')
-rw-r--r--ex4_9/Cargo.lock7
-rw-r--r--ex4_9/Cargo.toml6
-rw-r--r--ex4_9/src/main.rs25
3 files changed, 38 insertions, 0 deletions
diff --git a/ex4_9/Cargo.lock b/ex4_9/Cargo.lock
new file mode 100644
index 0000000..f86e65a
--- /dev/null
+++ b/ex4_9/Cargo.lock
@@ -0,0 +1,7 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 4
+
+[[package]]
+name = "ex4_9"
+version = "0.1.0"
diff --git a/ex4_9/Cargo.toml b/ex4_9/Cargo.toml
new file mode 100644
index 0000000..72bb2c2
--- /dev/null
+++ b/ex4_9/Cargo.toml
@@ -0,0 +1,6 @@
+[package]
+name = "ex4_9"
+version = "0.1.0"
+edition = "2024"
+
+[dependencies]
diff --git a/ex4_9/src/main.rs b/ex4_9/src/main.rs
new file mode 100644
index 0000000..08e47b5
--- /dev/null
+++ b/ex4_9/src/main.rs
@@ -0,0 +1,25 @@
+pub struct WrappingU32 {
+ value: u32,
+}
+
+impl From<u32> for WrappingU32 {
+ fn from(v: u32) -> Self {
+ Self{value:v}
+ }
+}
+
+fn main() {
+ println!("Hello, world!");
+}
+
+#[cfg(test)]
+mod tests {
+ use crate::*;
+
+ #[test]
+ fn t0() {
+ let n: u32 = 5;
+ let w: WrappingU32 = n.into();
+ assert_eq!(w.value,n);
+ }
+}