diff --git a/src/main.rs b/src/main.rs index e7a11a9..2561486 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,39 @@ fn main() { - println!("Hello, world!"); + + let args = vec![ + [0,0,0,1], + [0,1,1,0], + [1,1,1,1] + ]; + + println!(); + + for arg in args { + println!("{:?} {:12?}{:4?}{:4?}", + arg, + arg.iter() + .map(|i| i.to_string()) + .collect::(), + u32::from_str_radix( + &arg.iter() + .map(|i| i.to_string()) + .collect::(), + 2 + ).unwrap(), + binary_slice_to_number(&arg) + ); + } + + println!(); +} + +fn func(arg: &T) -> &T { + arg +} + +fn binary_slice_to_number(slice: &[u32]) -> u32 { + u32::from_str_radix( + &slice.iter().map(|i| i.to_string()).collect::(), + 2 + ).unwrap() }