TMI: blogging about Rust hacking, day 2
May. 2nd, 2012 10:14 pmI'm going to see if I can productively write these posts a bit at a time, during long compiles. Whee!
I mentioned how yesterday, I got everything to stop being broken and returned to a state in which the only thing that was breaking was my new test case. Here it is, btw:
// xfail-fast // aux-build:cci_class_cast.rs use cci_class_cast; import cci_class_cast::kitty::*; import to_str::*; import to_str::to_str; fn print_out<T: to_str>(thing: T, expected: str) { let actual = thing.to_str(); #debug("%s", actual); assert(actual == expected); } fn main() { let nyan : to_str = cat(0u, 2, "nyan") as to_str; print_out(nyan, "nyan"); }
I'm going to make the bold assumption that you already can read Rust (but if not, there's a tutorial that may or may not reflect the version of the language I'm using.) The test depends on an auxiliary crate; the "aux-build" directive in a comment tells our test runner to build it; the use directive links this program with the other crate, called cci_class_cast, and finally, the import directive imports the module kitty within the crate cci_class_cast. And yes, I try to make as many of my examples as possible involve cats. There's something wrong with that? ( Cut for length )