1 // Rust-101, Part 06: Lifetimes, Testing
2 // =====================================
10 impl PartialEq for BigInt {
11 fn eq(&self, other: &BigInt) -> bool {
12 debug_assert!(self.test_invariant() && other.test_invariant());
13 self.data == other.data
18 let b1 = BigInt::new(13);
19 let b2 = BigInt::new(37);
20 println!("b1 == b1: {} ; b1 == b2: {}; b1 != b2: {}", b1 == b1, b1 == b2, b1 != b2);
24 impl fmt::Debug for BigInt {
25 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
33 pub fn inc(&mut self, mut by: u64) {
34 panic!("Not yet implemented.");
41 let mut b = BigInt::new(1337);
43 assert!(b == BigInt::new(1337 + 1337));
46 assert_eq!(b, BigInt::from_vec(vec![0]));
48 assert_eq!(b, BigInt::from_vec(vec![1 << 63]));
50 assert_eq!(b, BigInt::from_vec(vec![0, 1]));
52 assert_eq!(b, BigInt::from_vec(vec![1 << 63, 1]));
54 assert_eq!(b, BigInt::from_vec(vec![0, 2]));