Created
December 16, 2014 19:55
-
-
Save zmack/07826f941366cdbad10c to your computer and use it in GitHub Desktop.
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
#[deriving(Show,Clone)] | |
enum DiskStruct { | |
File(String), | |
Dir(String) | |
} | |
impl DiskStruct { | |
fn new(path: &str) -> DiskStruct { | |
match path.slice_from(path.len()-1) { | |
"/" => DiskStruct::Dir(path.to_string()), | |
_ => DiskStruct::File(path.to_string()) | |
} | |
} | |
fn path(self) -> String { | |
match self { | |
DiskStruct::File(s) => s.clone(), | |
DiskStruct::Dir(s) => s.clone() | |
} | |
} | |
fn foo(&self) { | |
println!("Self is {}", (*self).clone().path()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment