Skip to content

Instantly share code, notes, and snippets.

@chamakits
chamakits / weird_borrowing_error.rs
Last active June 24, 2016 05:44 — forked from anonymous/playground.rs
Problemataic borrowing
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;
@chamakits
chamakits / playground.rs
Created June 24, 2016 05:11 — forked from anonymous/playground.rs
Shared via Rust Playground
struct StructNoLifetime {}
impl StructNoLifetime {
pub fn do_nothing(&mut self) {
}
}
struct StructWithLifetime <'a> {
pub field: &'a i32
}
fn main() {
@chamakits
chamakits / hello_rust1-1_prints.rs
Last active June 14, 2016 03:34 — forked from anonymous/playground.rs
Shared via Rust Playground
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");
}
@chamakits
chamakits / playground.rs
Created November 2, 2015 05:51 — forked from anonymous/playground.rs
Shared via Rust Playground
fn main() {
let s = "abc".to_string();
{
//println!("{}", s);
//sfun(s);
}
match s {
_ => {println!("{}", s)}
}
@chamakits
chamakits / playground.rs
Created October 28, 2015 05:50 — forked from anonymous/playground.rs
Shared via Rust Playground
// 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;