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 are two fixes:
-
make the field public
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![])
.