1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-11-30 17:15:23 +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

@@ -4,6 +4,6 @@ version = "0.1.0"
edition = "2021"
publish = false
[[bin]]
name = "offset-differences"
[lib]
name = "offset_differences"
path = "exercise.rs"

View File

@@ -11,7 +11,7 @@ Copy the following code to <https://play.rust-lang.org/> and make the tests
pass. Use an iterator expression and `collect` the result to construct the
return value.
```rust
```rust,editable
{{#include exercise.rs:offset_differences}}
todo!()
}

View File

@@ -51,5 +51,3 @@ fn test_degenerate_cases() {
assert_eq!(offset_differences(1, empty), vec![]);
}
// ANCHOR_END: unit-tests
fn main() {}