In the book's tutorial this pub is not necessary, right?

use crate::garden::vegetables::Asparagus;

pub mod garden;

fn main() {
    let plant = Asparagus {};
    println!("I'm growing {plant:?}!");
}

This pub is not necessary in the book's tutorials.

Instead, it makes sense to be in a library crate.

I think in that example no external library crate is used. So "mod garden" is needed for the compiler to find the garden.rs module which resides in the same src folder as main.rs. The leading pub seems to be not required. The use crate::garden::vegetables::Asparagus; makes the Asparagus type available directly, avoiding the long path garden::vegetables::Asparagus;. I assume the crate:: prefix is not needed in this case. I think the pub in pub mod garden would be a reexport of the garden module, which should be not required.

[EDIT]

Actually a related issue have been already reported, see remove pub qualifier by JonathonAnderson · Pull Request #4110 · rust-lang/book · GitHub

I don't think it's a re-export.

mod module loads a module into the module system, it's like creating a new path in a linux filesystem. But it is accessible only by children or sibling modules.

pub makes it accessible from parents or external crates, given the full path up to there is public as well.

A re-export works more closely like a symlink which is making it available at a new location, that of the re-export.

I do agree that pub is not needed there.

I agree, pub for reexport makes only sense for libraries, not for main.rs.

pub makes it accessible from anywhere, including external crates.

I don't think that the last part "including external crates." is correct and would make any sense?

It does make sense, but only for library crates; I don't think you could access it without the pub. So that's how they would be able to use it. So by "external crates" I meant simply crates that depend on it (as a library crate) i.e to use the API.

But I insist, that in my view at least, it is not re-exporting anything.