Skip to content

Commit 219bb98

Browse files
committed
format: use cargo fmt to format
1 parent 7ffa28f commit 219bb98

File tree

12 files changed

+388
-76
lines changed

12 files changed

+388
-76
lines changed

Cargo.lock

Lines changed: 145 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/default_judger.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ impl DefaultJudger {
1919
pub fn create_instance() -> Box<dyn Judger> {
2020
Box::new(DefaultJudger {})
2121
}
22-
}
22+
}

src/lib/src/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ impl Context {
1212
line_num: 0,
1313
}
1414
}
15-
}
15+
}

src/lib/src/env.rs

Lines changed: 65 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,70 @@ impl Env {
2222
let table = src_str.parse::<Table>()?;
2323

2424
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")? as i32,
28-
memory_limit: table.get("memory-limit").unwrap_or(&Value::from(1000000)).as_integer().ok_or("memory-limit should be Integer type")? as u64,
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")? as u64,
31-
runtime_limit: table.get("runtime-limit").unwrap_or(&Value::from(1000000)).as_integer().ok_or("runtime-limit should be Integer type")? as u64,
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")? as u64,
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")? as i32,
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")? as u64,
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+
as u64,
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")? as u64,
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")? as u64,
3689
})
3790
}
3891
}
@@ -108,4 +161,4 @@ mod tests {
108161
stderr = 'path/to/stderr' # The stdout path of the spawned process";
109162
assert!(Env::new(&config_str).is_err());
110163
}
111-
}
164+
}

0 commit comments

Comments
 (0)