// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. trait connection { fn read() -> int; } trait connection_factory { fn create() -> C; } type my_connection = (); type my_connection_factory = (); impl connection for () { fn read() -> int { 43 } } impl connection_factory for my_connection_factory { fn create() -> my_connection { () } } pub fn main() { let factory = (); let connection = factory.create(); let result = connection.read(); assert result == 43; }