Why is a "use" needed for env::args() but not Vec::new()?

Viewed 91

For env::args() I am having to explicitly include the env module by

use std::env;

But I am able to use Vec::new() without the use std::vec statement, though both are from the standard library.

Is there a subset of standard library modules that are made available by default for all programs?

2 Answers

Yes, everything in the Rust prelude (including std::vec::Vec) is available by default.

Yes, all programs implicitly import all members of the prelude module.

Related