2013-01-22 17:20:08 -08:00
|
|
|
struct SpeechMaker {
|
|
|
|
speeches: uint
|
|
|
|
}
|
|
|
|
|
2013-05-31 15:17:22 -07:00
|
|
|
impl SpeechMaker {
|
2013-08-02 21:41:06 -07:00
|
|
|
pub fn how_many(&self) -> uint { self.speeches }
|
2013-01-22 17:20:08 -08:00
|
|
|
}
|
|
|
|
|
2013-08-02 21:41:06 -07:00
|
|
|
fn foo(speaker: &SpeechMaker) -> uint {
|
2013-01-22 17:20:08 -08:00
|
|
|
speaker.how_many() + 33
|
|
|
|
}
|
|
|
|
|
2013-02-01 19:43:17 -08:00
|
|
|
pub fn main() {
|
2013-08-17 08:37:42 -07:00
|
|
|
let lincoln = SpeechMaker {speeches: 22};
|
2013-08-02 21:41:06 -07:00
|
|
|
assert_eq!(foo(&lincoln), 55);
|
2013-01-22 17:20:08 -08:00
|
|
|
}
|