Introducing a KVPair type
This commit is contained in:
		
							parent
							
								
									dd8b4ac28c
								
							
						
					
					
						commit
						79100fc50f
					
				| @ -119,6 +119,12 @@ enum RValue<'a> { | ||||
|     RVLiteral(&'a str), | ||||
| } | ||||
| 
 | ||||
| #[derive(Clone, Debug, PartialEq)] | ||||
| struct KVPair<'a> { | ||||
|     key: &'a str, | ||||
|     value: RValue<'a>, | ||||
| } | ||||
| 
 | ||||
| /// Any element significant to dust that isn't plain text
 | ||||
| ///
 | ||||
| /// These elements are always wrapped in curly braces
 | ||||
| @ -179,8 +185,11 @@ fn rvalue(i: &str) -> IResult<&str, RValue> { | ||||
| } | ||||
| 
 | ||||
| /// Parameters for a partial
 | ||||
| fn key_value_pair(i: &str) -> IResult<&str, (&str, RValue)> { | ||||
|     separated_pair(key, tag("="), rvalue)(i) | ||||
| fn key_value_pair(i: &str) -> IResult<&str, KVPair> { | ||||
|     map(separated_pair(key, tag("="), rvalue), |(k, v)| KVPair { | ||||
|         key: k, | ||||
|         value: v, | ||||
|     })(i) | ||||
| } | ||||
| 
 | ||||
| /// Display a value from the context
 | ||||
| @ -692,7 +701,10 @@ mod tests { | ||||
|                 "", | ||||
|                 ( | ||||
|                     "foo", | ||||
|                     Some(vec![("bar", RValue::RVPath(Path { keys: vec!["baz"] }))]) | ||||
|                     Some(vec![KVPair { | ||||
|                         key: "bar", | ||||
|                         value: RValue::RVPath(Path { keys: vec!["baz"] }) | ||||
|                     }]) | ||||
|                 ) | ||||
|             )) | ||||
|         ); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Tom Alexander
						Tom Alexander