Skip to content

Instantly share code, notes, and snippets.

@archer884
Forked from anonymous/playground.rs
Created August 17, 2016 04:07
Show Gist options
  • Save archer884/7bc5ae3610049ac3681415648566a3b2 to your computer and use it in GitHub Desktop.
Save archer884/7bc5ae3610049ac3681415648566a3b2 to your computer and use it in GitHub Desktop.
Rust code shared from the playground
use std::io::{self};
use std::result;
type KKResults <T> = Result <T, KKError>;
#[derive(Debug)]
enum KKError {
Io(io::Error),
}
impl From<io::Error> for KKError {
fn from(err: io::Error) -> KKError {
KKError::Io(err)
}
}
trait knightknave {
type Output;
fn is_knight_or_knave (&self) -> KKResults <Self::Output>;
}
struct Knight;
struct Knave;
struct visitor;
impl knightknave for visitor {
type Output = bool;
fn is_knight_or_knave(&self) -> KKResults<Self::Output> {
Ok(true)
}
}
fn main() {
println!("{:?}", visitor.is_knight_or_knave());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment