Tuple struct constructor complains about private fields

Posted by Grubermensch on Stack Overflow See other posts from Stack Overflow or by Grubermensch
Published on 2014-06-08T21:22:22Z Indexed on 2014/06/08 21:24 UTC
Read the original article Hit count: 391

Filed under:
|

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 following compiler error message:

tsh.rs:8:18: 8:31 error: cannot invoke tuple struct constructor with private fields
tsh.rs:8   let mut jobs = job::JobsList(vec![]);
                          ^~~~~~~~~~~~~

It's unclear to me what is being seen as private here. As you can see below, both of the structs are tagged with pub in my module file. So, what's the secret sauce?

tsh.rs

use std::io;

mod job;

fn main() {
  // Initialize jobs list
  let mut jobs = job::JobsList(vec![]);
  loop {
    /*** Shell runtime loop ***/
  }
}

job.rs

use std::fmt;

pub struct Job {
  jid: int,
  pid: int,
  cmd: String
}

impl fmt::Show for Job {
  /*** Formatter ***/
}

pub struct JobsList(Vec<Job>);

impl fmt::Show for JobsList {
  /*** Formatter ***/
}

© Stack Overflow or respective owner

Related posts about private

Related posts about rust