allow variables to have a default value of ""
This commit is contained in:
parent
b2911dbe1b
commit
0133731e97
|
@ -6,9 +6,14 @@ pub struct Variable {
|
|||
|
||||
impl From<String> for Variable {
|
||||
fn from(string: String) -> Variable {
|
||||
let id_value: Vec<&str> = string.split('\n').collect();
|
||||
let id_value: Vec<&str> = string.lines().collect();
|
||||
let id = id_value[0].replace("VAR ", "").to_string();
|
||||
let initial_value = id_value[1].to_string();
|
||||
|
||||
let initial_value = if id_value.len() == 1 {
|
||||
"".to_string()
|
||||
} else {
|
||||
id_value[1..].join("")
|
||||
};
|
||||
|
||||
Variable { id, initial_value }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue