-
-
Save archer884/7bc5ae3610049ac3681415648566a3b2 to your computer and use it in GitHub Desktop.
Rust code shared from the playground
This file contains 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::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