rust_demos 0.1.0

Aa demo crate
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
fn main(){
	let scores:Vec<i16>=vec![1,2,3,4];
	let mut score_iter=scores.iter().clone();
	for i in scores.iter(){
		println!("{}",i);
	}
	//--------Consumer adaptor---------
	//println!("Count of scores :{}",scores_iter.count());
	//println!("Sum of the scores :{}",score_iter.sum::<i16>());
	//println!("Last element in scores :{:?}",score_iter.last());
	//println!("3rd element :{:?}",score_iter.nth(3));

	let num_cubes:Vec<i16>=score_iter.map(|x| x*x*x).collect(); //produces (Iterator adaptor)
	println!("Cubes of scores :{:?}",num_cubes);

}