Showing posts with label rust. Show all posts
Showing posts with label rust. Show all posts

Tuesday, May 21, 2019

What is a Closure ? How can it be used in Rust programming ? - PART1

Closures in Rust

Closure is record storing a function along with it environment variables. You can read about closures in wiki

Difference between Closure and a function.

function definition:
Note: we have to explicitly pass the type and variable.
fn add (x:u32) -> u32 { x +1 }

Closure definition in Rust:
Note: We can follow any one of the following syntax to define a Closure
//explicitly defining types
let add = |x:u32| -> u32 { x +1 }
or
//the compiler dynamically type the Closure variables
let add = |x| -> {x+1}
or
//ignoring curly braces if you have only one statement
let add = |x| -> x+1

We will go through some example for Closure and discuss its features

Example#1 - passing Closure to a function

Below example shows the closure is defined with parameter ’ x ’ passed from environment where it is called. Closure is enclosed in a variable called square_x here.
We can see that value of the variable x is 2 . In the main program, first we define the Closure and then it is called from square_x(x) in println! statement.
square_x is the Closure.
When Closure looks for it's required variable's 'x' value for calculation, Closure its self will be enclosed with its required variables and understand that 'x' is parameter and it need to get its value from lexical environment which is 2 . And it perform the calculation: x*x - square of 2 which is 4.

The second print statement execute inside the function square . When we call the square(square_x) function, Closure invoked and looks for its lexical environment and find the value for parameter ‘x’ variable.The ‘x’ variable value is 3 over there, so the Closure calculate the square of 3 which is 9 .

fn square<T>(sq:T)
 where T:Fn(i32) -> i32
  {
    let  x = 3;
    println!("square called from insidefn value = {}",sq(x));
  }

fn main() {

    let mut x = 2;
    let square_x  =  |x| x*x;
    println!("square of x = {}",square_x(x));
   

    square(square_x);

}

From what we learned , Closure doesn’t need to specify it’s Parameters type or Return type. But in the (square) function definition, we explicitly defined ‘T’ as Fn(i32) -> i32.
Because for a function, it is necessary to define it's parameters type.

run in Rust Playground -
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=c7dafb2aa3b7f7f83fc7490be6f30925

Example 2 # What will happen if we are not passing variable

This example we remove the passing parameter, to make the Closure as no-parameters.

let sq = || x*x;

But Closure has the property to get all its variables from its lexical environment . When you pass it to a function, it actually pass the Closure and along with variables enclosed.

fn square<T>(sq:T)
 where T:Fn() -> i32
  {
    let  x = 3;
    println!("square called from insidefn value = {}",sq());
  }

fn main() {
    let x = 2;    
    let square_x  =  || x*x;
    println!("square of x = {}",square_x());
    square(square_x);
 
}

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=adc2ce2cb7fc2f73ddee5e1cbfe10a9d

Example 3- What will happen if you pass different variable to Closure in the above example

fn square<T>(sq:T)
 where T:Fn(i32) -> i32
  {
    let  x = 3;
    println!("square called from insidefn value = {}",sq(x));
  }

fn main() {

    let x = 2;
    let square_x  =  |y| x*x;

    square(square_x);
    println!("square of x = {}",square_x(x));
}

Can you guess the output ?Hint : Closure is record which stores function along with its environment variables.
run the example above and check out the output.
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=7763c76893f87426f975db3eafab5e0f

Reference https://doc.rust-lang.org/rust-by-example/fn/closures.html

https://doc.rust-lang.org/book/ch13-00-functional-features.html

Tuesday, March 12, 2019

Rust Iterators

iterators

Iterators in Rust programming

Nowadays Iterators are every programmer’s tool in hand.When I program array of objects/strings in C programming , I always wish that I could have some tool/function/operator where we can iterate through these objects or strings(words). “for” loop or “while” loop are going through array index in C programming .

If you are storing words in Array it become 2 dimensional array. So iterating through “words” become even more difficult in C programming .But it will be convenient if you can iterate through the types values/objects in the array. eg: Array(“I”,“like”,“rust”,“programming”) …if you can just iterate through the words rather than reading through the letters, it will be easy to make the words manipulations.

It is Functional programming style where we can just tell the program to iterate through the specified type .
Another use case would be eg: In the given Array (2,4,6,8) of elements if we want to find cube for all the elements in the array and then filter if cube is even number.

For conventional Loop structure we will be iterating through each element and find cube then check and filter if it is even. How great it would be if we can have something like below give us the same output number/maths calculations

example: array.iter().filter(x/2==0).collect()

eg2: words or sentence manipulation

array.iter().filter( words_contains_vowels)

It improves the readability of the program a lot. This functional programming style improves the readability ,but at the same time we can’t compromise the performance . Since they are as fast as our native loops , they are “Zero cost abstraction” in Rust ## iter from standard library The standard library std::iter provides Trait is Iterator. You want to build iterator any Struct ,

you can implement Iterator on your collection with below trait

trait Iterator { type Item fn next(&mut self) ->Option(Self::Item); }

In the below example, suppose if I have an input stream coming from outside and I want to iterator over word by word

//the structure which store the words and index of the words
//note :Since we are using String slice reference , the life time needs to provided explicitly 

struct Mystream<'a>{
    words: Vec<&'a str>,
    index:usize
}

//implementing the structure with methods "new" and "next_word"
//"new" method create a structure object with words generated from  stream
//next_word method calls next method in the Iterator trait

impl <'a>Mystream<'a>{

//"new" method get the string and split them into words vector
//index will be zero for object, but we will increment it in each iteration and use it as indexing the vector
    fn new(stream:&'a str) -> Mystream{
        Mystream{
             words : stream.split(' ').collect(),
             index:0,
        }
    }

//next_word method calls the "next" method from the iterator trait    
    
    fn next_word(&mut self) ->Option<&'a str>{
            self.next()
    }

}

//standard implementation for Iterator for "Mystream" struct

impl <'a>Iterator for Mystream<'a>{
    type Item = &'a str;
    
    fn next(&mut self) -> Option<&'a str>{
            self.index +=1;
            match Some(self.words[self.index]){
                Some(word) => Some(word),
                None => None,
            }
    }
}



fn main(){
    
    let mut mystream = Mystream::new("I like to implement Rust Iterator for my stream");
    let mut len = mystream.words.len();
    println!("{:?},{}",mystream.words[0],len);
    len = len -1;
    while len > 0 {
    
         println!("{:?},{}",mystream.next_word().unwrap(),len);
         len = len -1;
    }
    
}

Not sure above example is tough one, but let me try to explain it… Let assume we have a stream of words coming from input port, our task is to store it in a struct as words .(ie: split the sentence into words). I tried to explain most of the things in the comment section. But still we will go through it … The implementation of Iterator for “Mystream” struct is important part in the code. For understanding Iterator implementation you should know what is trait and struct creation and implementation of struct in rust

Iterator

If look at the Iterator trait documentation, they ask us to create an associated type Item (Associated types are a way of associating a type placeholder with a trait such that the trait method definitions can use these placeholder types in their signatures.) and required method “next

The next method passing parameter and return parameters are mentioned in the example.

As a general rule , for any Trait Rust documentation you will get the required methods or associated types needs to implemented for using it for your struct. Also we need to implement that Trait for our struct.
This case,

impl <'a>Iterator for Mystream<'a>

Since we are using vector of string slice(a reference type), we need to provide life time for it and struct.

Here we have given the associated type Item as &'a str (string slice) which means we are planning to iterate through string slice when the next method calls.

Return type for next method is Option <Self:Item> which means we need use match keyword to return Some(word) if there is value and None if nothing.

In the case Collection types: we can use the
Array,Vec, Hash etc with iter metod.



use std::collections::HashMap;

fn main(){
    let arr = [1,2,3];
    let v = vec![4,5,6];
    let mut h = HashMap::new();
    h.insert(1,"naveen");
    h.insert(2,"davis");
    h.insert(3,"tom");
    println!("{:?}",arr.iter());
    
    for i in arr.iter(){
        println!("{}",i);
    }
    
    for i in v.iter(){
        println!("{}",i);
    }
    
    for (i,name) in h.iter(){
        println!("{:?}",name);
    }
    
    println!("{:?}",arr.iter().next()); //this is going print only first element
    println!("{:?}",arr.iter().next()); //this is going print only first element
    println!("{:?}",arr.iter().next()); //this is going print only first element
    println!("{:?}",arr.iter().next()); //this is going print only first element
    
    println!("{:?}",h.iter().next());  //this is going print only first element
    println!("{:?}",h.iter().next());  //this is going print only first element
    println!("{:?}",h.iter().next());  //this is going print only first element
    println!("{:?}",h.iter().next());  //this is going print only first element
}
iterator_cont

Iter

We can iterate through collection in 3 ways

  • iter(), which iterates over &T.
  • iter_mut(), which iterates over &mut T.
  • into_iter(), which iterates over T.

iterate through immutable reference , in this case we are not supposed to change the value and but we using only reference to value

Rule one: any borrow must last for a scope no greater than that of the owner
Rule two: you may have EITHER 1+ immutable borrows OR EXACTLY 1 mutable borrow

What happens when we compile this code ?
If you have already gone through some Rust program before, you will shout immediately  "compile time" error. As the vector moved in the first for loop and ownership has transfered, so when you try to use it again in the main the value was already dropped. We can use reference to the values to avoid this problem.

True . Rust won't allow to 
fn main() {
   
   let v = vec![3,4,5,7];
   
   for i in v {
      
            println!("{:?}",i);
   }
   
   for i in v {
       println!("{}",i);
   }
   
}

```rust_errors
use of moved value: `v`
  --> src/main.rs:10:13
   |
5  |    for i in v {
   |             - value moved here
...
10 |    for i in v {
   |             ^ value used here after move

In the below example , we solve above problem passing reference to for loop,
You can either use v.iter() or &v


fn main() {
   
   let v = vec![3,4,5,7];
   
   for i in &v {
      
            println!("{:?}",i);
   }
   
   for i in v.iter() {
       println!("{}",i);
   }
   
   println!("{:?}",v);
   
}

If you really want to pass the ownership to the for loop,
use either v or v.into_iter()


fn main() {
   
   let v = vec![3,4,5,7];

   for i in v.into_iter() {
       println!("{}",i);
   }
   
   println!("{:?}",v);
   
}
```rust_errors
 for i in v.into_iter() {
   |             - value moved here
...
11 |    println!("{:?}",v);
   |                    ^ value borrowed here after move
   |
   = note: move occurs because `v` has type `std::vec::Vec<i32>`

Another scenario is you want to update or change the value inside the for loop
you can either pass &mut v or you can use v.iter_mut()

fn main() {
   
   let mut v = vec![3,4,5,7];
   
   for i in &mut v {
      
        *i +=1;
       println!("{:?}",i);
   }
   
   println!("\nsecond iteration to change values\n");
   for i in v.iter_mut() {
      
        *i +=1;
       println!("{:?}",i);
   }
   
   println!("{:?}",v);
   
}

IntoIterator

If you want to use ’ for’ loop in your type, you will need to build the trait IntoIterator for the type.

We will see how to implement an IntoIterator for our type.

IntoIterator

Let build a ‘for’ loop for your Struct

How nice it would be if you can do a for loop which iterate through

[derive(Debug)]
struct Sentence{
    words: Vec<String>,
}

impl IntoIterator for Sentence {
    type Item = String;
    type IntoIter = std::vec::IntoIter<std::string::String>;
    fn into_iter(self) -> Self::IntoIter {
        self.words.into_iter()
    }
}


fn main() {

    let sentence = Sentence { 
        words: vec!["one".to_string(), "two".to_string()]
    };
    
    for word in sentence{
        println!("{}",word.contains("w"))
    }
   
}
Standard Output
false
true

In the above example we are creating Sentence Struct which our type. In that we are storing words as Vector elements.

As we discussed in IntoIterator trait implementation, we need to implement the trait for our type Sentence

So two associated types are required ,

one is Item which is the item we are iterating through.
second is IntoIter ie in which type we are iterating through. here it is std::vec::IntoIterstd::string::String

Note: if it were a vector of integers , it would be std::vec::IntoIter

The required method for IntoIterator trait is into_iter which is also implemented with Rust document mentioned parameter and return type.

Wednesday, December 26, 2018

Fundamentals of Webassembly

I was reading more on the WebAssembly last week.wrote about JavaScript in the last post, I don't know whether I have given wrong feeling that we should not study JavaScript at all. I did not meant that.In fact we should study JavaScript to understand more on the internals and browser JS engines .

The only thing I meant , we are in need finding alternative ways for more robust/new languages to replace JS drawbacks.

Web Assembly + Rust can offer some of the replacement for JS drawbacks. read more https://webassembly.org/


I don't know I know good enough to write this post, but still writing..


How to start with Web Assembly + Rust:


You can read webassembly+ rust on  https://rustwasm.github.io/book/why-rust-and-webassembly.html


In Ubuntu Linux machine probably we need the below steps to run webassembly with rust:

1. You need Rust tool chain: rustc, rustup and Cargo   . read the below link for rust tool chain - https://www.rust-lang.org/tools/install


2. wasm-pack - is a one shop for building testing Rust+webassembly applications.
 read about wasm-pack here https://rustwasm.github.io/wasm-pack/installer/

  wasm-pack has prerequisite for  Rust and npm. Since we installed rust in the above step, we only need npm to install ( if you haven't installed)

npm is a package manager for JavaScript. You can install it from https://www.npmjs.com/get-npm


You can get a project template with following ..

Clone a project template with this command:

cargo generate --git https://github.com/rustwasm/wasm-pack-template

you can follow below steps from the document to start with it .. https://rustwasm.github.io/book/game-of-life/hello-world.html




How to access Document elements(DOM ) using Webassembly+Rust

We need wasm_bindgen and web_sys libraries to access the DOM elements with Rust. You can read more about web_sys here -https://rustwasm.github.io/wasm-bindgen/api/web_sys/






Code: lib.rs

extern crate wasm_bindgen;
extern crate web_sys;

mod utils;

use wasm_bindgen::prelude::*;

use wasm_bindgen::JsCast;
use web_sys::{Document, Element, HtmlElement, Window};


#[wasm_bindgen(start)]
pub fn run() {
    using_web_sys();
}


fn using_web_sys()-> Result<(),JsValue>{
use web_sys::console;

console::log_1(&"Hellowrld to console using websys".into());

let window = web_sys::window().expect("no global window exists");
let document = window.document().expect("no document  found");

let body  = document.body().expect("document should have a body");


let val = document.create_element("p")?;

    val.set_inner_html("Hello from 121Rust!");
val.set_attribute("id","p1");
body.append_child(&val);
        let element = document
.get_element_by_id("p2").expect("no p2 element found");

let element1 = document
.get_element_by_id("p1").expect("no p1 element found");


let att = element.text_content().expect("no element text found");

let att1 = element1.text_content().expect("no element text found");
console::log_1(&att.into());

console::log_1(&att1.into());
    Ok(())

}

cargo.toml:

[package]
name = "na-rust-web"
version = "0.1.0"
authors = ["naveen "]

[lib]
crate-type = ["cdylib", "rlib"]


[dependencies]
cfg-if = "0.1.2"
wasm-bindgen = "0.2.29"
#web-sys = { version = "0.3.6", features = ['console'] }

# The `console_error_panic_hook` crate provides better debugging of panics by
# logging them with `console.error`. This is great for development, but requires
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
# code size when deploying.
console_error_panic_hook = { version = "0.1.1", optional = true }

# `wee_alloc` is a tiny allocator for wasm that is only ~1K in code size
# compared to the default allocator's ~10K. It is slower than the default
# allocator, however.
#
# Unfortunately, `wee_alloc` requires nightly Rust when targeting wasm for now.
wee_alloc = { version = "0.4.2", optional = true }

[dev-dependencies]
wasm-bindgen-test = "0.2.29"


[dependencies.web-sys]
version = "0.3.4"
features = [
  'Document',
  'Element',
  'HtmlElement',
  'Node',
  'Window',
  'console',
]
profile.release]
# Tell `rustc` to optimize for small code size.

opt-level = "s"




 











Monday, November 26, 2018

Algorithms - sorting algorithms implementation in Rust programming langage

It's important for programmer to do deep dive into algorithms some point of time. but I never tried to do that. As ECE( electronics) branch never needed algorithms in their curriculum, i nicely ignored algorithms . But become unavoidable thing for any kind of application development/programming . its becoming essential to have some ideas or ready made algorithms or approaches in hand to start with some innovative ideas to convert as applications.  So thought of refreshing the algorithms from basics.

If you are learning new language , and trying to solve/implement those basics algorithms , that would be the ideal way to learn them.

And here we are trying to solve/implement some algorithms or problems through Rust programming language.

1. Merge function - https://davnav.github.io/rustgeeks/rust_merge_sortedvectors.html
2.Insert Sort - https://github.com/davnav/rustgeeks/blob/master/rust_insertsort.md
3. Longest string - https://davnav.github.io/rustgeeks/rust_LongestString.html

Tuesday, November 20, 2018

A new documentation started with Algorithms/problem solutions with Rust programming language


Rust for Geeks:


The problems/algorithms can be Easy,Medium or Hard. If you are newbie to programming , you might have noticed most of the schools/colleges start with “C Programming “ language.
But as an alternative , I would recommend, start with Rust programming language. As you all know C was early computer language and created on 1989. Computer programming languages were evolving over the years.So in a way we can say Rust programming languages evolved over 30 years programming language researches. So its better to start with Rust programming language if you are beginning. But you can learn C/other languages also.

so visit my new github page:

Wednesday, September 26, 2018

multiple termnial at the same screen - Ubuntu

I started using multiple screen in my office to do multiple tasking. I thought it was not going to save my time  and efficiency. But I experienced that it was highly improving my work efficiency. I was able to finish my tasks quickly without much tiring when doing multi-tasking.

But when i reach home and open the laptop, its highly difficult for me switch between screens.

So I was searching for a tool where i can create multi-terminal on the same screen.

you can use terminator

the installation is simple

apt-get install terminator

open a terminal and type
$terminator 

you will get a terminal open by terminator , then you can split it using ctrl +shift +o





Monday, August 6, 2018

Rust on Amazon EC2

Amazon EC2 is very popular nowadays. So wanted to try something with EC2., not sure how much its going to cost me .Usually I stop amazon experiments when I reach the credit card page. :-)

This time really wanted to try what is EC2.

I took the basic plan and lauched a Ubuntu server and installed Rustc, cargo and gcc.

Its really exciting to login to remote machine and experiment some really  installation and programming as we do in our local machine.


Tuesday, July 17, 2018

managed to write a file from terminal input - Rust

My Text editor program in Rust programming language managed to get input characters from screen terminal as created a file once program ends.

Read the code here
https://github.com/davnav/RustEditor/blob/master/main.rs


If I started writing this in C, i would have end up in "Segmentation fault". But even though Rust compiler makes you learn the syntax and new concepts ( mutation,scope,borrow etc) . But once we managed to compile the code, the program produces the output as we expected.(won't go to the buffer overflows or pointer problems)

Terminal is not pointing to left most position when I hit enter, looks like I need to handle this manually.




I have not build any 'struct' for 'Editor' or 'Rows'. Not sure much syntax for 'struct' in Rust.  Reading more this now.


 I think I can move to the 'text viewer' pages in the below documentation.
https://viewsourcecode.org/snaptoken/kilo/04.aTextViewer.html

Monday, July 9, 2018

Finally refreshed the terminal screen

It was always a big question in me that all schooling/engineering  programming  courses( C or assembly)  teach Fibonacci series or some tough logic program ( something like for a given number 'N' search the subset bla bla .. ) . But when I looked at the computer , I wondered how they build these screens/commands and applications.. is it with Maths ?  is it with Fibonacci series /prime numbers? (They are not, it made up of simple logics.. but its like a 'building blocks' game)

My expectation from computer classes was  to build some screens or applications ,  ( but generally I got bored with theory . there was my fault too , i admit ) . Computer applications/commands  did not look like mathematical problem ,But computer subjects seems to me as  mathematics subject. ( I know they really need maths, when we deep dive).

But as a beginner, I misunderstood that someone who knows deep maths can only do something with computer .. but actually that is not the case.

Whatever programs I studied/taught to  do something with stdin ( standard input) or stdout( standard /the screen), are something like 'reverse string' or 'search character', but they did not generate any motivation to build some real world applications, rather I got scared even to attempt/read big programs, thinking it might require big logical algorithms that my brain can't digest.  but as student I always wanted to build something like 'vi' (editor) or some commands or something having windows (not Microsoft windows) screen. At least I wanted to know how these functionalities are coming in the screen.
When I build some functionality that actual 'vi' editor has , I feels like I am writing programs as a professional (Really its not the case)

Having said all these story :-)  as a hobby project , I am  trying to build an editor based on the documentation https://viewsourcecode.org/snaptoken/kilo/03.rawInputAndOutput.html

I am learning lot of things when I wanted my program to do some functionality that 'vi' editor does.

More over I am trying to build this in Rust language  which is a new generation  computer programming language , capable of replacing 'C' language. Every system programmers should try to learn it as per http://web.stanford.edu/class/cs140e/

:-)


My text editor draft , just refreshed the screen :-)
https://github.com/davnav/RustEditor



The clear screen functionality can be easily built with below code, but it was never known to me ( as I know only Fibonacci ... :-) )

// Refresh the screen by writing "x1b[2J" byte to screen
io::stdout().write(b"\x1b[2J");
println!();

// align the cursor to the left top by writing  "\x1b[H" byte to screen
io::stdout().write(b"\x1b[H");



but be aware , Rust compiler is ruthless :-) . it makes us read the documentation thoroughly.










Wednesday, July 4, 2018

do we need to take care 'String' type carefully ?

When I tried to do something with "Strings" in C programming language, either it won't give the desired result or I end up in 'Segmentation fault'. Lot of books in C show "Strings" manipulating with pointers. I like C in the sense  that we can access the characters with the memory where they sit. But when  I compile the full program, it compiles without any error , but finally  when I run it , normally I endup in "Segmentation fault".


So thought of learning some string manipulation/Methods in Rust Programming language.

https://doc.rust-lang.org/std/string/struct.String.html#method.from




Sunday, January 21, 2018

Crates and Modules in Rust Language

I was trying to jump into Rust programming language through Rocket web framework. I know it might be a tough attend to directly start with Rocket without much understanding on the Rust syntax.

I believe I have a minimum understanding on Rust syntax and I thought let learn it reverse way , whenever something comes strange or unknown ,let go reverse and goto the basics.

 So, with that strategy when I jump to Rocket , I came across lot of new things.. Ofcourse Rust has lot of new syntax , terminologies. But since I had some prior knowledge on Flask,Django web frameworks, I did not stunt by the folder structures and initial quick start steps.

but it is really fun learning it in reverse way, lot of new things to understand.

One thing was Crates and Modules. It not a new idea, but it a new term and building it in Rust is quite easy.

We have a good documentation from these from Rust developers.

As per my understanding,

If you know python, we will be using packages there. Similar way we can use Crates to build modules and import them into our program.

I hope below documentation will be enough to read through it and try it.

https://doc.rust-lang.org/book/first-edition/crates-and-modules.html

https://rustbyexample.com/attribute/crate.html

Saturday, July 9, 2016

Rust applicatons

Are searching some of the applications written in Rust? below you have some of the interesting applications.

1. http://www.redox-os.org/  - operating system written in Rust
2. http://zinc.rs/ - Zinc is an experimental attempt to write an ARM stack that would be similar to CMSIS or mbed in capabilities
3. http://maidsafe.net/ - Maidsafe, a company that tries to create an encrypted, completely decentralized "successor" to the internet
4.https://github.com/servo/servo - Servo, the new browser engine being developed by Mozilla 
5. Iron is a high level web framework built in and for Rust, built on hyper.
ironframework.io/doc/iron/

6. wtftw, a tiling window manager - https://kintaro.github.io/rust/window-manager-in-rust-01/

Friday, June 24, 2016

Rust pointer implementaiton

https://aml3.github.io/RustTutorial/html/02.html#Starting_to_Corrode:%3Cbr%3EPointers,_Memory,_Strings,_and_I/O

I am really scared of pointers in C programming itself.. Rust have more features than C for pointers .. :-)


But this really good read the above link on Rust memory management. I believe that there are lot of values for learning these new features .

Rust vs C program speed

I was just going through some of the Rust programs and tutorials...

This is one of the site which benchmark programing language speed. Rust programming language doesn't compromise the speed

http://benchmarksgame.alioth.debian.org/u64q/rust.html

http://benchmarksgame.alioth.debian.org/why-measure-toy-benchmark-programs.html


If you are really looking for some Rust applications , here you can browse.

http://pcwalton.github.io/blog/2013/05/20/safe-manual-memory-management/


This is one good link for those who want to start with Rust - https://aml3.github.io/RustTutorial/