summaryrefslogblamecommitdiff
path: root/meap/meap-code/ch3/ch3-adding-pub-to-file.rs
blob: b5ade57fa6d37de6433c1a4f6b750491067ca26a (plain) (tree)



























                                   
#[derive(Debug,PartialEq)]
pub enum FileState {
  Open,
  Closed,
}

#[derive(Debug)]
struct File {
  pub name: String,
  data: Vec<u8>,
  pub state: FileState,
}

impl File {
  pub fn new(name: &str) -> File {
    File {
        name: String::from(name), 
        data: Vec::new(), 
        state: FileState::Closed
    }
  }
}

fn main() {
  let f7 = File::new("f7.txt");
  //...
  println!("{:?}", f7);
}