Book: Chapter 20.2: Initial code on `src/lib.rs`

Created on 11 Dec 2020  路  6Comments  路  Source: rust-lang/book

Hello, great work on the rust book. However, I noted this and thought to mention it.

The example after Listing 20-12 in src/lib.rs should be:

#![allow(unused)]
pub struct ThreadPool;

fn main() {}

rather than

#![allow(unused)]
fn main() {
pub struct ThreadPool;
}

as described in the book

[UPDATE]
The example should actually be:

pub struct Thread pool; 

without any main function, so I think this is more of disabling or removing the "show hidden lines" button on this example.

Enhancement

Most helpful comment

If you click "show hidden lines", this appears. This is because of the way that rustdoc adds code to samples that don't have main in them.

All 6 comments

@tolumide-ng could you clarify where do you see the following snippet in the book?

fn main() {
    pub struct ThreadPool;
}

I checked right after Listing 10-12 in https://doc.rust-lang.org/book/ch20-02-multithreaded.html#creating-a-similar-interface-for-a-finite-number-of-threads, and I don't see it.

If you click "show hidden lines", this appears. This is because of the way that rustdoc adds code to samples that don't have main in them.

got it, thanks @steveklabnik !

Hello, @novito would you be raising a fix for this?

hey @tolumide-ng - I would be happy to fork the repo and open a PR for this, but since you originally raised the issue, I invite you to do so. Check out the contributing guidelines.

@steveklabnik recently revised this 馃ズ
[UPDATE]
The example should actually be:

pub struct Thread pool; 

without any main function on lib.rs, so I think this is more of disabling or removing the "show hidden lines" button on this specific example.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

carols10cents picture carols10cents  路  5Comments

xStrom picture xStrom  路  4Comments

nathany picture nathany  路  3Comments

mikebenfield picture mikebenfield  路  3Comments

istarus picture istarus  路  4Comments