Created
August 29, 2014 20:35
-
-
Save bartolsthoorn/db519f113d6e8afe7af4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Node { | |
Text(String), | |
Element(String, Vec<Node>) | |
} | |
impl Node { | |
fn stringify(&self) -> String { | |
match *self { | |
Text(s) => s, | |
Element(name, nodes) => | |
"<".to_string() + name + ">".to_string() + | |
nodes.iter().map(|node| node.stringify()).concat() + | |
"</".to_string() + name + ">".to_string() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
error: type
core::iter::Map<'_,&Node,collections::string::String,core::slice::Items<'_,Node>>
does not implement any method in scope namedconcat
nodes.iter().map(|node| node.stringify()).concat()