A private item was used outside its scope.
Erroneous code example:
#![allow(unused)]
fn main() {
mod foo {
const PRIVATE: u32 = 0x_a_bad_1dea_u32; // This const is private, so we
// can't use it outside of the
// `foo` module.
}
println!("const value: {}", foo::PRIVATE); // error: constant `PRIVATE`
// is private
} In order to fix this error, you need to make the item public by using the pub keyword. Example:
#![allow(unused)]
fn main() {
mod foo {
pub const PRIVATE: u32 = 0x_a_bad_1dea_u32; // We set it public by using the
// `pub` keyword.
}
println!("const value: {}", foo::PRIVATE); // ok!
}
© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/error_codes/E0603.html