You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/lib/src/env.rs
+65-12Lines changed: 65 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -22,17 +22,70 @@ impl Env {
22
22
let table = src_str.parse::<Table>()?;
23
23
24
24
Ok(Self{
25
-
cwd: table.get("cwd").unwrap_or(&Value::from("./")).as_str().ok_or("cwd should be String type")?.to_string(),
26
-
large_stack: table.get("large-stack").unwrap_or(&Value::from(false)).as_bool().ok_or("large-stack should be Boolean type")?,
27
-
max_process: table.get("max-process").unwrap_or(&Value::from(1)).as_integer().ok_or("max-process should be Integer type")? asi32,
28
-
memory_limit: table.get("memory-limit").unwrap_or(&Value::from(1000000)).as_integer().ok_or("memory-limit should be Integer type")? asu64,
29
-
output_file: table.get("output").unwrap_or(&Value::from("./out")).as_str().ok_or("output should be String type")?.to_string(),
30
-
output_size_limit: table.get("output-size-limit").unwrap_or(&Value::from(100000)).as_integer().ok_or("output-size-limit should be Integer type")? asu64,
31
-
runtime_limit: table.get("runtime-limit").unwrap_or(&Value::from(1000000)).as_integer().ok_or("runtime-limit should be Integer type")? asu64,
32
-
stderr: table.get("stderr").ok_or("Stderr don't have default value").unwrap().as_str().ok_or("stderr should be String type")?.to_string(),
33
-
stdin: table.get("stdin").ok_or("Stdin don't have default value").unwrap().as_str().ok_or("stdin should be String type")?.to_string(),
34
-
stdout: table.get("stdout").ok_or("Stdout don't have default value").unwrap().as_str().ok_or("stdout should be String type")?.to_string(),
35
-
lang: table.get("lang").unwrap_or(&Value::from(0)).as_integer().ok_or("lang should be Integer type")? asu64,
25
+
cwd: table
26
+
.get("cwd")
27
+
.unwrap_or(&Value::from("./"))
28
+
.as_str()
29
+
.ok_or("cwd should be String type")?
30
+
.to_string(),
31
+
large_stack: table
32
+
.get("large-stack")
33
+
.unwrap_or(&Value::from(false))
34
+
.as_bool()
35
+
.ok_or("large-stack should be Boolean type")?,
36
+
max_process: table
37
+
.get("max-process")
38
+
.unwrap_or(&Value::from(1))
39
+
.as_integer()
40
+
.ok_or("max-process should be Integer type")? asi32,
41
+
memory_limit: table
42
+
.get("memory-limit")
43
+
.unwrap_or(&Value::from(1000000))
44
+
.as_integer()
45
+
.ok_or("memory-limit should be Integer type")? asu64,
46
+
output_file: table
47
+
.get("output")
48
+
.unwrap_or(&Value::from("./out"))
49
+
.as_str()
50
+
.ok_or("output should be String type")?
51
+
.to_string(),
52
+
output_size_limit: table
53
+
.get("output-size-limit")
54
+
.unwrap_or(&Value::from(100000))
55
+
.as_integer()
56
+
.ok_or("output-size-limit should be Integer type")?
57
+
asu64,
58
+
runtime_limit: table
59
+
.get("runtime-limit")
60
+
.unwrap_or(&Value::from(1000000))
61
+
.as_integer()
62
+
.ok_or("runtime-limit should be Integer type")? asu64,
63
+
stderr: table
64
+
.get("stderr")
65
+
.ok_or("Stderr don't have default value")
66
+
.unwrap()
67
+
.as_str()
68
+
.ok_or("stderr should be String type")?
69
+
.to_string(),
70
+
stdin: table
71
+
.get("stdin")
72
+
.ok_or("Stdin don't have default value")
73
+
.unwrap()
74
+
.as_str()
75
+
.ok_or("stdin should be String type")?
76
+
.to_string(),
77
+
stdout: table
78
+
.get("stdout")
79
+
.ok_or("Stdout don't have default value")
80
+
.unwrap()
81
+
.as_str()
82
+
.ok_or("stdout should be String type")?
83
+
.to_string(),
84
+
lang: table
85
+
.get("lang")
86
+
.unwrap_or(&Value::from(0))
87
+
.as_integer()
88
+
.ok_or("lang should be Integer type")? asu64,
36
89
})
37
90
}
38
91
}
@@ -108,4 +161,4 @@ mod tests {
108
161
stderr = 'path/to/stderr' # The stdout path of the spawned process";
0 commit comments