blob: eb293118acc869c85624fe7112692a067287b5ae (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
A private item was used outside its scope.
Erroneous code example:
```compile_fail,E0603
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:
```
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!
```
|