-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathcode.rs
More file actions
70 lines (65 loc) · 2.18 KB
/
code.rs
File metadata and controls
70 lines (65 loc) · 2.18 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//! Code in config
use serde::{Deserialize, Serialize};
fn default_pick() -> String {
"${fid}.${slug}".into()
}
fn default_submission() -> String {
"${fid}.${slug}.${sid}.${ac}".into()
}
fn default_enable_rust_crates() -> bool {
true
}
/// Code config
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Code {
#[serde(default)]
pub editor: String,
#[serde(rename(serialize = "editor-args"), alias = "editor-args", default)]
pub editor_args: Option<Vec<String>>,
#[serde(rename(serialize = "editor-envs"), alias = "editor-envs", default)]
pub editor_envs: Option<Vec<String>>,
#[serde(default, skip_serializing)]
pub edit_code_marker: bool,
#[serde(default, skip_serializing)]
pub start_marker: String,
#[serde(default, skip_serializing)]
pub end_marker: String,
#[serde(rename(serialize = "inject_before"), alias = "inject_before", default)]
pub inject_before: Option<Vec<String>>,
#[serde(rename(serialize = "inject_after"), alias = "inject_after", default)]
pub inject_after: Option<Vec<String>>,
#[serde(default, skip_serializing)]
pub comment_problem_desc: bool,
#[serde(default, skip_serializing)]
pub comment_leading: String,
#[serde(default, skip_serializing)]
pub test: bool,
#[serde(default = "default_enable_rust_crates")]
pub enable_rust_crates: bool,
pub lang: String,
#[serde(default = "default_pick", skip_serializing)]
pub pick: String,
#[serde(default = "default_submission", skip_serializing)]
pub submission: String,
}
impl Default for Code {
fn default() -> Self {
Self {
editor: "vim".into(),
editor_args: None,
editor_envs: None,
edit_code_marker: false,
start_marker: "".into(),
end_marker: "".into(),
inject_before: None,
inject_after: None,
comment_problem_desc: false,
comment_leading: "".into(),
test: true,
enable_rust_crates: default_enable_rust_crates(),
lang: "rust".into(),
pick: "${fid}.${slug}".into(),
submission: "${fid}.${slug}.${sid}.${ac}".into(),
}
}
}