Skip to content

Commit e2035eb

Browse files
committed
move some code to lib.rs in order to show docs
1 parent 4784201 commit e2035eb

2 files changed

Lines changed: 18 additions & 16 deletions

File tree

src/lib.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/// Hello from Magrathea
2+
pub fn answer() -> u32 {
3+
42
4+
}
5+
6+
#[cfg(test)]
7+
mod tests {
8+
use super::*;
9+
10+
#[test]
11+
fn deep_thought_test() {
12+
assert_eq!(answer(), 42);
13+
}
14+
}

src/main.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
11
fn main() {
2-
println!("The answer to the ultimate question is {}", answer());
3-
}
4-
5-
/// Hello from Magrathea
6-
fn answer() -> u32 {
7-
42
8-
}
9-
10-
#[cfg(test)]
11-
mod tests {
12-
use super::*;
13-
14-
#[test]
15-
fn deep_thought_test() {
16-
assert_eq!(answer(), 42);
17-
}
2+
println!(
3+
"The answer to the ultimate question is {}",
4+
rust_gh_example::answer()
5+
);
186
}

0 commit comments

Comments
 (0)