|
@ -1,3 +1,39 @@ |
|
|
fn main() {
|
|
|
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::<String>(),
|
|
|
|
|
|
u32::from_str_radix(
|
|
|
|
|
|
&arg.iter()
|
|
|
|
|
|
.map(|i| i.to_string())
|
|
|
|
|
|
.collect::<String>(),
|
|
|
|
|
|
2
|
|
|
|
|
|
).unwrap(),
|
|
|
|
|
|
binary_slice_to_number(&arg)
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
println!();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn func<T>(arg: &T) -> &T {
|
|
|
|
|
|
arg
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn binary_slice_to_number(slice: &[u32]) -> u32 {
|
|
|
|
|
|
u32::from_str_radix(
|
|
|
|
|
|
&slice.iter().map(|i| i.to_string()).collect::<String>(),
|
|
|
|
|
|
2
|
|
|
|
|
|
).unwrap()
|
|
|
}
|
|
|
}
|