'struct

One aspect of many languages that is useful is to have a variable that lives for the lifetime of the entire application. While some purists argue that having a variable that lasts for the life of an application is not good practice, they cannot argue that it has its uses.

Within Rust, we can also do this using a special struct type, a lifetime struct:

let version: &'static str = "v1.3, 22nd May 2016";  

Local type inference allows us to omit the type when it is not global, so this is equivalent to the above when inside a function:

let version = "v1.3, 22nd May 2016"; 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset