1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-12-02 01:21:59 +02:00

Be more consistent about tests vs. main (#2644)

The content slides all use `fn main`, with the exception of the testing
segment. But with this change, where it makes sense exercises use tests
instead, and not both tests and `fn main`.

A small change in `book.js` supports running tests when a code sample
does not have `fn main` but does have `#[test]`, so these work
naturally.

Fixes #1581.
This commit is contained in:
Dustin J. Mitchell
2025-02-18 15:13:16 -05:00
committed by GitHub
parent 699c5137c7
commit 44a79741ff
38 changed files with 138 additions and 144 deletions

View File

@@ -50,13 +50,6 @@ impl User {
}
}
// ANCHOR: main
fn main() {
let bob = User::new(String::from("Bob"), 32, 155.2);
println!("I'm {} and my age is {}", bob.name, bob.age);
}
// ANCHOR_END: main
// ANCHOR: tests
#[test]
fn test_visit() {