I'm trying to use
a struct from a value.rs
file from chunk.rs
, but it is not working. This is my current file hierarchy.
src
|
|---value.rs
|---chunk.rs
|---other files
Here is my value.rs
code:
pub enum Value {
}
pub struct ValueArray {
values: Vec<Value>,
}
pub impl Value {
pub fn new() -> Value {
Value {
values: Vec::new(),
}
}
pub fn write_chunk(&mut self, value: Value) {
self.code.push(value);
}
}
Here is my chunk.rs
code:
use crate::value::ValueArray; // Error Here
pub enum OpCode {
OpReturn,
}
pub struct Chunk {
pub code: Vec<OpCode>,
constants: value::ValueArray,
}
impl Chunk {
pub fn new() -> Chunk {
Chunk {
code: Vec::new(),
constants: value::ValueArray::new(),
}
}
pub fn write_chunk(&mut self, byte: OpCode) {
self.code.push(byte);
}
}
This is my exact error message:
unresolved import `crate::value`
could not find `value` in the crate rootrustc(E0432)
chunk.rs(1, 12): could not find `value` in the crate root
I'm not sure why it isn't working since I've done something very similar in another sibling file. I'm new to Rust, so I appreciate all of your help. Thanks