In standard Rust code, the vec!
macro is in the prelude and there is no need to make it visible manually. I'm working on a library that doesn't use the standard library and sets #![no_std]
, so also the prelude isn't visible.
Inside the test code, I am using functionality from the standard library, therefore I have a
#[cfg(test)]
extern crate std;
This works without problems to access functions and datatypes from the standard library, but now I would like to access the vec!(...)
macro and I don't know how.
use std::vec::vec!;
results in an error:
expected one of `::`, `;`, or `as` here
at the position of the exclamation mark.
How can I access this macro instead?