This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct NoLifetime {} | |
struct WithLifetime <'a> { | |
pub field: &'a i32 | |
} | |
fn main() { | |
let mut some_val = NoLifetime{}; | |
borrow_mut_function(&mut some_val); | |
borrow_mut_function(&mut some_val);//Borrowing as mutable for the second time. | |
let num = 5; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct StructNoLifetime {} | |
impl StructNoLifetime { | |
pub fn do_nothing(&mut self) { | |
} | |
} | |
struct StructWithLifetime <'a> { | |
pub field: &'a i32 | |
} | |
fn main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
println!("Hello everyone!"); | |
println!(r#"First line! | |
We are here to learn about the language "{}", | |
a really neat language."#, | |
"Rust"); | |
println!("Multiline.\ | |
Ignores leading whitespace and newline"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let s = "abc".to_string(); | |
{ | |
//println!("{}", s); | |
//sfun(s); | |
} | |
match s { | |
_ => {println!("{}", s)} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// open.rs | |
use std::error::Error; | |
use std::fs::File; | |
use std::io::prelude::*; | |
use std::path::Path; | |
use std::char; | |
fn main() { | |
let a = 'a' as u32; | |
let outer = 25; |