25 lines
619 B
Rust
25 lines
619 B
Rust
pub fn make_arr(s: &str) -> Vec<i32> {
|
|
s.trim_matches(&['[', ']'][..])
|
|
.split(',')
|
|
.map(|x| {
|
|
let x = x.trim();
|
|
if x == "null" {
|
|
-1
|
|
} else {
|
|
x.parse::<i32>().unwrap()
|
|
}
|
|
})
|
|
.collect()
|
|
}
|
|
|
|
pub fn make_matrix(s: &str) -> Vec<Vec<i32>> {
|
|
s.trim_matches(&['[', ']'][..])
|
|
.split("],[")
|
|
.map(|row| {
|
|
row.trim_matches(&['[', ']'][..])
|
|
.split(',')
|
|
.map(|x| x.trim().parse::<i32>().unwrap())
|
|
.collect()
|
|
})
|
|
.collect()
|
|
} |