Created
April 16, 2016 04:08
-
-
Save anonymous/daaa33069786915e9ebee3274c3e27b8 to your computer and use it in GitHub Desktop.
Shared via Rust Playground
This file contains hidden or 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
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 { | |
// get all a-priori possibilities | |
fn get_all_possibilities() -> Iterator<Item=T>; | |
} | |
#[derive(Debug,Clone)] | |
pub struct ExampleInfo(HashSet<u32>); | |
impl ExampleInfo { | |
pub fn new() -> ExampleInfo { ExampleInfo(HashSet::new()) } | |
} | |
impl Info<Value> for ExampleInfo { | |
fn get_all_possibilities() -> Iterator<Item=Value> { VALUES.iter() as Iterator<Item=Value> } | |
} | |
fn main() { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment