#[std]
#[header("This file tests Oak's doc subcommand.")]
#[doc("This constant is a constant.")]
const CONSTANT = 3;
const TEST = CONSTANT + 5;
#[doc("This structure represents a given date in time.
A Date object has three members:
|Member|Value|
|-|-|
|`month: num` | The month component of the date |
|`day: num` | The day component of the date |
|`year: num` | The year component of the date |")]
struct Date {
let month: num,
day: num,
year: num;
#[doc("The constructor used to create a date.")]
fn new(month: num, day: num, year: num) -> Date {
return [month, day, year];
}
#[doc("Print the date object to STDOUT")]
fn print(self: &Date) {
putnum(self->month); putchar('/');
putnum(self->day); putchar('/');
putnumln(self->year);
}
}
#[doc("This function takes a number `n` and returns `n * n`, or `n` squared.")]
fn square(n: num) -> num {
return n * n
}
fn main() {
let d = Date::new(5, 14, 2002);
d.print();
}