Day 10 & Day 11

July 17, 2017 20:58 UTC Team Serv0101 (Servo) [2017]Subscribe to this teams's activities

Last weekend we had the meetup with the local rust community members.
In the meetup, we learned about references and borrowing. We will cover these topic breifly in coming blogs.
It was the great time spending with Rust community people and we also met one of our coach who introduced us to this community.

Things we learned:
* Iterator and Enumerator:
fn main () {
Let foo = vec![1, 3, 7, 9, 12, 25, 27];
for (i, item) in foo.iter().enumerate() {
println!("the { }th item is { }", i+1, item);
the 1th item is 1
the 2th item is 3
the 3th item is 7
so on...

Iterator: It gives us a sequence of things.
Enumerator: Creates an iterator which gives iteration count as well as the next value.

Generic Data Type : It is more flexible, provide more functionality and remove code duplication.

Generic function -->
fn foo(list:&[T]) ->T

Here T : Type parameter
The function foo is generic over some type T. It has one parameter named list and type of list is a slice of values of type T
The foo function will return a value of the same type T.


You must be logged in to add a comment.