I am working on a basic shell interpreter to familiarize myself with Rust. While working on the table for storing suspended jobs in the shell, I have gotten stuck at the fol
As the error message suggests, the problem is JobsList
has a private field, that is, the Vec<Job>
value is inaccessible outside the module that defines the struct
. This means that you cannot pattern match on a JobsList
value to extract it, and that you cannot construct it directly.
There's two fixes:
pub struct JobsList(pub Vec<Job>);
provide a public constructor
impl JobsList {
pub fn new(jobs: Vec<Job>) -> JobsList {
JobsList(jobs)
}
}
called like JobsList::new(vec![])
.