]> git.ralfj.de Git - rust-101.git/blobdiff - workspace/src/part10.rs
remove workspace from the repository, instead generate a zipfile to upload
[rust-101.git] / workspace / src / part10.rs
diff --git a/workspace/src/part10.rs b/workspace/src/part10.rs
deleted file mode 100644 (file)
index 570e851..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-// Rust-101, Part 09: Closures (WIP)
-// =================================
-
-use std::io::prelude::*;
-use std::io;
-
-use part05::BigInt;
-
-trait Action {
-    fn do_action(&mut self, digit: u64);
-}
-
-impl BigInt {
-    fn act_v1<A: Action>(&self, mut a: A) {
-        for digit in self {
-            a.do_action(digit);
-        }
-    }
-}
-
-struct PrintWithString {
-    prefix: String,
-}
-
-impl Action for PrintWithString {
-    fn do_action(&mut self, digit: u64) {
-        println!("{}{}", self.prefix, digit);
-    }
-}
-
-fn print_with_prefix_v1(b: &BigInt, prefix: String) {
-    let my_action = PrintWithString { prefix: prefix };
-    b.act_v1(my_action);
-}
-
-pub fn main() {
-    let bignum = BigInt::new(1 << 63) + BigInt::new(1 << 16) + BigInt::new(1 << 63);
-    print_with_prefix_v1(&bignum, "Digit: ".to_string());
-}
-
-impl BigInt {
-    fn act<A: FnMut(u64)>(&self, mut a: A) {
-        for digit in self {
-            a(digit);
-        }
-    }
-}
-
-pub fn print_with_prefix(b: &BigInt, prefix: String) {
-    b.act(|digit| println!("{}{}", prefix, digit) );
-}
-