You've already forked comprehensive-rust
mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-07-05 06:00:30 +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:
committed by
GitHub
parent
699c5137c7
commit
44a79741ff
@ -4,6 +4,6 @@ version = "0.1.0"
|
||||
edition = "2021"
|
||||
publish = false
|
||||
|
||||
[[bin]]
|
||||
[lib]
|
||||
name = "eval"
|
||||
path = "exercise.rs"
|
||||
|
@ -46,7 +46,7 @@ evaluate to `85`. We represent this as a much bigger tree:
|
||||
|
||||
In code, we will represent the tree with two types:
|
||||
|
||||
```rust,editable
|
||||
```rust
|
||||
{{#include exercise.rs:Operation}}
|
||||
|
||||
{{#include exercise.rs:Expression}}
|
||||
|
@ -127,13 +127,3 @@ fn test_zeros() {
|
||||
);
|
||||
}
|
||||
// ANCHOR_END: tests
|
||||
|
||||
fn main() {
|
||||
let expr = Expression::Op {
|
||||
op: Operation::Div,
|
||||
left: Box::new(Expression::Value(10)),
|
||||
right: Box::new(Expression::Value(2)),
|
||||
};
|
||||
println!("expr: {expr:?}");
|
||||
println!("result: {:?}", eval(expr));
|
||||
}
|
||||
|
Reference in New Issue
Block a user