Clean up old unused code.
This commit is contained in:
		
							parent
							
								
									a5585eb01f
								
							
						
					
					
						commit
						ec889bc868
					
				| @ -197,32 +197,6 @@ pub fn always_fail<'r, 's>(_context: Context<'r, 's>, input: &'s str) -> Res<&'s | ||||
|     )))) | ||||
| } | ||||
| 
 | ||||
| /// Walk backwards unconsuming blank lines and line endings.
 | ||||
| ///
 | ||||
| /// List items are a special case where the trailing blank lines do not belong to it, unlike all other elements. Rather than write that special logic into each child parser, this just walks backwards through the consumed input to unconsume trailing blank lines and line breaks.
 | ||||
| #[tracing::instrument(ret, level = "debug")] | ||||
| pub fn regurgitate<'s>(input: &'s str, remaining: &'s str) -> &'s str { | ||||
|     assert!(is_slice_of(input, remaining)); | ||||
|     let mut offset = remaining.as_ptr() as usize - input.as_ptr() as usize; | ||||
|     let source = &input[..offset]; | ||||
|     let mut char_indices = source.char_indices().rev(); | ||||
|     loop { | ||||
|         match char_indices.next() { | ||||
|             Some((off, chr)) => { | ||||
|                 if chr == '\n' { | ||||
|                     offset = off; | ||||
|                 } else if chr != ' ' && chr != '\t' { | ||||
|                     return &input[offset..]; | ||||
|                 } | ||||
|             } | ||||
|             None => { | ||||
|                 // It was all whitespace, so return the full input string
 | ||||
|                 return input; | ||||
|             } | ||||
|         }; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| #[tracing::instrument(ret, level = "debug")] | ||||
| pub fn whitespace_eof(input: &str) -> Res<&str, &str> { | ||||
|     recognize(tuple((multispace0, eof)))(input) | ||||
| @ -256,14 +230,4 @@ mod tests { | ||||
|         assert!(is_slice_of(input, yellow_heart)); | ||||
|         assert_eq!(yellow_heart, "💛"); | ||||
|     } | ||||
| 
 | ||||
|     #[test] | ||||
|     fn regurgitate_unicode() { | ||||
|         let input = "🧡💛\n\t   \t  \n\n💚💙💜"; | ||||
|         let (green_heart_index, _) = input.char_indices().skip(12).next().unwrap(); | ||||
|         let starting_with_green_heart = &input[green_heart_index..]; | ||||
|         let after_yellow = regurgitate(input, starting_with_green_heart); | ||||
|         assert!(is_slice_of(input, after_yellow)); | ||||
|         assert_eq!(after_yellow, "\n\t   \t  \n\n💚💙💜"); | ||||
|     } | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Tom Alexander
						Tom Alexander