panic if shell desired as not impl
This commit is contained in:
52
src/play.rs
52
src/play.rs
@@ -20,21 +20,22 @@ fn from_string(s: String) -> String {
|
||||
fn parse(s: String) -> Vec<String> {
|
||||
let s = s
|
||||
.split("\n")
|
||||
.filter(|x: &&str| !x // doesnt start with #
|
||||
.split_whitespace()
|
||||
.collect::<Vec<_>>()
|
||||
.join("")
|
||||
.starts_with("#")
|
||||
)
|
||||
.map(|x| x
|
||||
.split("#")
|
||||
.take(1) // drop after #
|
||||
.collect::<Vec<_>>()
|
||||
.join("")
|
||||
.split_whitespace()
|
||||
.collect::<Vec<_>>()
|
||||
.join(" ")
|
||||
)
|
||||
.filter(|x: &&str| {
|
||||
!x // doesnt start with #
|
||||
.split_whitespace()
|
||||
.collect::<Vec<_>>()
|
||||
.join("")
|
||||
.starts_with("#")
|
||||
})
|
||||
.map(|x| {
|
||||
x.split("#")
|
||||
.take(1) // drop after #
|
||||
.collect::<Vec<_>>()
|
||||
.join("")
|
||||
.split_whitespace()
|
||||
.collect::<Vec<_>>()
|
||||
.join(" ")
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n");
|
||||
let mut channels = vec![];
|
||||
@@ -44,21 +45,23 @@ fn parse(s: String) -> Vec<String> {
|
||||
match lines[i] {
|
||||
"" => {
|
||||
j = 0;
|
||||
},
|
||||
}
|
||||
_ => {
|
||||
while channels.len() <= j {
|
||||
channels.push("".to_string());
|
||||
}
|
||||
channels[{ let tmp = j; j += 1; tmp }] += &(" ".to_string() + lines[i]);
|
||||
},
|
||||
channels[{
|
||||
let tmp = j;
|
||||
j += 1;
|
||||
tmp
|
||||
}] += &(" ".to_string() + lines[i]);
|
||||
}
|
||||
};
|
||||
}
|
||||
channels
|
||||
.iter()
|
||||
.map(|x| x.split_whitespace().collect::<Vec<_>>()
|
||||
.join(" ")
|
||||
)
|
||||
.collect()
|
||||
.map(|x| x.split_whitespace().collect::<Vec<_>>().join(" "))
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -111,9 +114,6 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn drop_comment_trailer() {
|
||||
assert_eq!(
|
||||
super::new("a b c # hello world")[0],
|
||||
"a b c".to_string()
|
||||
);
|
||||
assert_eq!(super::new("a b c # hello world")[0], "a b c".to_string());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user