Skip to content

Instantly share code, notes, and snippets.

View greister's full-sized avatar
🎯
Focusing

greister

🎯
Focusing
View GitHub Profile
use std::rc::Rc;
use std::ops::Deref;
trait HasPosition{
fn get_position(&self) -> i32;
}
struct Body {
position: i32
}
@greister
greister / playground.rs
Created April 18, 2016 15:54 — forked from anonymous/playground.rs
Shared via Rust Playground
use std::rc::Rc;
use std::ops::Deref;
//A HasPosition trait and a Body that implements it
trait HasPosition {
fn get_position(&self) -> i32;
}
struct Body {
position: i32
@greister
greister / playground.rs
Created April 18, 2016 15:36 — forked from anonymous/playground.rs
Shared via Rust Playground
use std::rc::Rc;
use std::ops::Deref;
//A HasPosition trait and a Body that implements it
trait HasPosition {
fn get_position(&self) -> i32;
}
struct Body {
position: i32
@greister
greister / playground.rs
Created April 17, 2016 14:38 — forked from anonymous/playground.rs
Shared via Rust Playground
pub trait Ast<'a> {
fn evaluate(self: Box<Self>) -> Option<Box<Ast<'a> + 'a>>;
}
pub struct Assignment<'a> {
lhs: Option<Box<Ast<'a> + 'a>>,
rhs: Option<Box<Ast<'a> + 'a>>
}
impl<'a> Ast<'a> for Assignment<'a> {
@greister
greister / playground.rs
Created April 17, 2016 06:31 — forked from anonymous/playground.rs
Shared via Rust Playground
fn main() {
do_stuff((42, 0));
do_stuff((0, 42));
do_stuff((0, 0));
do_stuff((123, 456));
}
fn do_stuff(point: (u32, u32)) {
match point {
@greister
greister / playground.rs
Created April 16, 2016 08:45 — forked from anonymous/playground.rs
Shared via Rust Playground
use std::thread;
use std::sync::Arc;
use std::rc::Rc;
use std::fmt::Debug ;
pub fn get_insertion_index<K: Ord + Debug + Clone>(values: &[K], k: &K) -> usize {
let mut index = 0;
for v in values{
if *v >= *k { break;}
index += 1;
@greister
greister / playground.rs
Created April 16, 2016 04:10 — forked from anonymous/playground.rs
Shared via Rust Playground
use std::hash::Hash;
use std::collections::{HashMap, HashSet};
use std::slice;
pub type Value = u32;
// list of values, assumed to be small to large
pub static VALUES: [Value; 5] = [1, 2, 3, 4, 5];
@greister
greister / playground.rs
Created April 16, 2016 04:09 — forked from anonymous/playground.rs
Shared via Rust Playground
use std::hash::Hash;
use std::collections::{HashMap, HashSet};
use std::slice;
pub type Value = u32;
// list of values, assumed to be small to large
pub static VALUES: [Value; 5] = [1, 2, 3, 4, 5];
@greister
greister / playground.rs
Created April 16, 2016 04:09 — forked from anonymous/playground.rs
Shared via Rust Playground
use std::hash::Hash;
use std::collections::{HashMap, HashSet};
use std::slice;
pub type Value = u32;
// list of values, assumed to be small to large
pub static VALUES: [Value; 5] = [1, 2, 3, 4, 5];
@greister
greister / playground.rs
Created April 16, 2016 04:08 — forked from anonymous/playground.rs
Shared via Rust Playground
use std::hash::Hash;
use std::collections::{HashMap, HashSet};
pub type Value = u32;
// list of values, assumed to be small to large
pub const VALUES : [Value; 5] = [1, 2, 3, 4, 5];
pub trait Info<T> where T: Hash + Eq + Clone + Copy {