Skip to content

Instantly share code, notes, and snippets.

@greister
Forked from anonymous/playground.rs
Created April 16, 2016 04:09
Show Gist options
  • Save greister/d2e5f818d16dddb20aaf5b60ada70211 to your computer and use it in GitHub Desktop.
Save greister/d2e5f818d16dddb20aaf5b60ada70211 to your computer and use it in GitHub Desktop.
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];
pub trait Info<T, I: Iterator<Item=T>> where T: Hash + Eq + Clone + Copy {
// get all a-priori possibilities
fn get_all_possibilities() -> I;
}
#[derive(Debug,Clone)]
pub struct ExampleInfo(HashSet<u32>);
impl ExampleInfo {
pub fn new() -> ExampleInfo { ExampleInfo(HashSet::new()) }
}
impl Info<&'static Value, slice::Iter<'static, Value>> for ExampleInfo {
fn get_all_possibilities() -> slice::Iter<'static, Value> {
VALUES.iter()
}
}
fn main() {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment