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
| /* Sample bubble sort program in Rust. | |
| Tested to compile with rust-0.6. | |
| */ | |
| extern mod std; | |
| extern mod benchmark; | |
| use benchmark::Benchmark; | |
| #[cfg(std_swap)] | |
| fn swap(arr: &mut [uint], left: uint, right: uint) { | |
| use core::vec; |
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
| use std::fmt; | |
| use std::io::net::tcp::TcpStream; | |
| use std::io::net::ip::{Ipv4Addr, SocketAddr}; | |
| use std::io::buffered::BufferedStream; | |
| #[deriving(Clone)] | |
| pub struct RustBot { | |
| nick: ~str, | |
| user: ~str, | |
| stream: BufferedStream<TcpStream>, |
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
| //! Source file for the `game` crate. | |
| #![allow(dead_code)] | |
| /// The `Player` trait. | |
| pub trait Player { | |
| /// Gets called when it's time for this player to take their turn. | |
| /// | |
| /// The game is played by sending commands on `pipe` and checking | |
| /// the responses that are returned. | |
| fn take_turn(&self, pipe: &PlayerActionPipe, round: uint); |