Hello,
I want to write a struct with getter methods. I get an error that the Self constructor can only be used with tuple or unit structs. Can someone explain what this means? Thanks!
//common.rs
pub enum OpCode {
OpConstant,
OpReturn,
Halt
}
pub struct CodeChunk {
code:Vec<OpCode>,
data:Vec<f64>,
source_lines:Vec<i32>
}
impl CodeChunk {
pub fn new() -> CodeChunk {
Self {
code:Vec::new(),
data:Vec::new(),
source_lines:Vec::new()
}
}
pub fn get_code_chunk(&self) -> Vec<OpCode>{
Self.code
}
...
}