Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std;
- import std::io::*;
- iface ninja_str {
- fn to_str() -> str;
- }
- impl of ninja_str for str {
- fn to_str() -> str { self }
- }
- impl of ninja_str for [str] {
- fn to_str() -> str {
- alt vec::len(self) {
- 0u { "" }
- x {
- vec::foldl(self[0], vec::slice(self, 1u, x)) {|iter, y|
- iter + ", " + y
- }
- }
- }
- }
- }
- // this works fine
- fn print<T: ninja_str>(str: T) {
- println(str.to_str());
- }
- impl ninja_file for writer {
- // this causes 'error: internal error in instantiate'
- fn build<T: ninja_str>(str: T) {
- self.write(str::bytes(str.to_str()));
- }
- }
- fn main() {
- //let n = result::get(mk_file_writer("build.ninja", [create]));
- //n.build("hello, world" as ninja_str);
- print("hello, world");
- }
Advertisement
Add Comment
Please, Sign In to add comment