summaryrefslogtreecommitdiff
path: root/meap/meap-code/ch3/ch3-adding-pub-to-file.rs
blob: b5ade57fa6d37de6433c1a4f6b750491067ca26a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#[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);
}