Website Summary Files Commits Branches @commit @diff @stats
path: root / homework / 81030 / 1,2-rust2html / example.rs
blob: 396aa0cdfc42276a2fb7d71d0fbf8b90d9bf00f2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
 * The following function returns the first answer.
 * It takes no arguments and returns an unsigned integer.
 */
fn answer1() -> usize {
    return 42; // answer to the Ultimate Question of Life, the Universe, and Everything
}

/*
 * The following function returns the second answer.
 * It takes no arguments and returns a floating-point number.
 */
fn answer2() -> f64 {
    return -4.2;
}

/*
 * The following function returns the third answer.
 * It takes no arguments and returns a single character.
 */
fn answer3() -> char {
    return 'E';
}

fn main() {
    println!("The \"First Answer\" is: '{}'", answer1());
    println!("The \"Second Answer\" is: '{}'", answer2());
    println!("The \"Third Answer\" is: '{}'", answer3());
}