About debug_assert and prelude

Hi guys,
I found that debug_assert is not contained in core prelude, but I can use it directly, How does this happen? Many thanks!


fn main() {

Seems like an oversight that it isn't there. As for how you can use it anyway: The prelude is effectively #[macro_use] extern crate core; use core::prelude::rust_2021::*;. The #[macro_use] imports all macros at the top level of libcore, which includes debug_assert!.

1 Like

got it. So debug_assert is in fact brought into scope by macro_use in this line,not by means of prelude.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.