Explorar el Código

Added Cargo.toml, did some other stuff

Lorenz Bung hace 8 años
padre
commit
afb9ac7c88
Se han modificado 3 ficheros con 35 adiciones y 4 borrados
  1. 6
    0
      hw6/task2/Cargo.toml
  2. 13
    0
      hw6/task2/src/command.rs
  3. 16
    4
      hw6/task2/src/shell.rs

+ 6
- 0
hw6/task2/Cargo.toml Ver fichero

1
+[package]
2
+name = "task2"
3
+version = "0.1.0"
4
+authors = ["Lorenz Bung <lorenz.bung@googlemail.com>"]
5
+
6
+[dependencies]

+ 13
- 0
hw6/task2/src/command.rs Ver fichero

1
+enum Command {
2
+    Empty,
3
+    Exit,
4
+    Cd(Option<OsString>),
5
+}
6
+
7
+impl Command {
8
+}
9
+
10
+impl FromStr for Command {
11
+    fn from_str(s: &str) -> Result<Self, Self::Err> {
12
+    }
13
+}

+ 16
- 4
hw6/task2/src/shell.rs Ver fichero

1
+use std::io;
2
+use std::io::prelude::*;
3
+
1
 struct Shell<R, W> {
4
 struct Shell<R, W> {
2
     pub reader: R,
5
     pub reader: R,
3
     pub writer: W,
6
     pub writer: W,
30
 }
33
 }
31
 
34
 
32
 impl BufRead for Shell<R, W> {
35
 impl BufRead for Shell<R, W> {
33
-    fn fill_buf(&mut self) -> Result<&[u8]> {}
34
-    fn consume(&mut self, amt: usize) {}
36
+    fn fill_buf(&mut self) -> Result<&[u8]> {
37
+        let buf = match stdin.fill_buf() {
38
+            Ok(res) => res,
39
+            Err(e) => return Err(e),
40
+        }
41
+        buf.unwrap()
42
+    }
43
+    fn consume(&mut self, amt: usize) {
44
+    }
35
 }
45
 }
36
 
46
 
37
 impl Write for Shell<R, W> {
47
 impl Write for Shell<R, W> {
38
-    fn write(&mut self, buf: &[u8]) -> Result<usize> {}
39
-    fn flush(&mut self) -> Result<()> {}
48
+    fn write(&mut self, buf: &[u8]) -> Result<usize> {
49
+    }
50
+    fn flush(&mut self) -> Result<()> {
51
+    }
40
 }
52
 }
41
 
53
 
42
 
54
 

Loading…
Cancelar
Guardar