5

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?

Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
Manohar
  • 3,865
  • 11
  • 41
  • 56
  • 3
    See also: [What is the prelude?](https://stackoverflow.com/questions/36384840/what-is-the-prelude) – kmdreko Feb 13 '22 at 19:11

2 Answers2

4

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

Jonathan Feenstra
  • 2,534
  • 1
  • 15
  • 22
4

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

Kamil Koczurek
  • 696
  • 5
  • 15