mainmatter / 100-exercises-to-learn-rust

A self-paced course to learn Rust, one exercise at a time.
https://rust-exercises.com
3.67k stars 734 forks source link

05_ticket_v2/05_nullability code example does not compile/run #132

Open michaelkebe opened 4 weeks ago

michaelkebe commented 4 weeks ago

Chapter 5.5 Nullability

https://rust-exercises.com/100-exercises/05_ticket_v2/05_nullability#tuples

Clicking the run icon produces:

   Compiling playground v0.0.1 (/playground)
error[E0425]: cannot find value `second` in this scope
 --> src/main.rs:3:12
  |
3 | assert_eq!(second.0, -42);
  |            ^^^^^^ not found in this scope

error[E0425]: cannot find value `second` in this scope
 --> src/main.rs:4:12
  |
4 | assert_eq!(second.1, 3);
  |            ^^^^^^ not found in this scope

error[E0425]: cannot find value `second` in this scope
 --> src/main.rs:5:12
  |
5 | assert_eq!(second.2, 8);
  |            ^^^^^^ not found in this scope

For more information about this error, try `rustc --explain E0425`.
error: could not compile `playground` (bin "playground") due to 3 previous errors

The code right above is not included in the snippet. It should be included, but hidden.

hdoordt commented 4 weeks ago

This is an issue with multiple other code snippets, too. For now, I'd suggest disabling running the incomplete code examples. In a later stage, I agree it would be good to include and hide the setup code in the examples

LukeMathWalker commented 4 weeks ago

It was never the intention for code samples to be runnable as-is, that's a side-effect of using mdbook and failing to annotate all snippets 😅 I agree the solution is to mark them as no-run.