X-Git-Url: https://git.ralfj.de/rust-101.git/blobdiff_plain/4f61be32dd480f23a7fef05ee66c42ae27c980c6..ab7f9b241429bd675b437d2437799de75d2f409b:/workspace/src/part08.rs?ds=inline diff --git a/workspace/src/part08.rs b/workspace/src/part08.rs deleted file mode 100644 index d02cad5..0000000 --- a/workspace/src/part08.rs +++ /dev/null @@ -1,38 +0,0 @@ -// ***Remember to enable/add this part in `main.rs`!*** - -// Rust-101, Part 08: Associated Types, Modules (WIP) -// ================================================== - -use std::cmp; -use std::ops; -use std::fmt; -use part05::BigInt; - -// Add with carry, returning the sum and the carry -fn overflowing_add(a: u64, b: u64, carry: bool) -> (u64, bool) { - let sum = u64::wrapping_add(a, b); - if sum >= a { // first addition did not overflow - unimplemented!() - } else { // first addition *did* overflow - unimplemented!() - } -} - -/*#[test]*/ -fn test_overflowing_add() { - assert_eq!(overflowing_add(10, 100, false), (110, false)); - assert_eq!(overflowing_add(10, 100, true), (111, false)); - assert_eq!(overflowing_add(1 << 63, 1 << 63, false), (0, true)); - assert_eq!(overflowing_add(1 << 63, 1 << 63, true), (1, true)); - assert_eq!(overflowing_add(1 << 63, (1 << 63) -1 , true), (0, true)); -} - -impl ops::Add for BigInt { - type Output = BigInt; - fn add(self, rhs: BigInt) -> Self::Output { - let mut result_vec:Vec = Vec::with_capacity(cmp::max(self.data.len(), rhs.data.len())); - unimplemented!() - } -} - -// [index](main.html) | [previous](part07.html) | [next](main.html)