Function mz_repr_test_util::extract_literal_string
source ยท pub fn extract_literal_string<I>(
first_arg: &TokenTree,
rest_of_stream: &mut I,
) -> Result<Option<String>, String>
Expand description
If the stream starts with a sequence of tokens that can be parsed as a datum, return those tokens as one string.
Sequences of tokens that can be parsed as a datum:
- A Literal token, which is anything in quotations or a positive number
- An null, false, or true Ident token
- Punct(-) + a literal token
If the stream starts with a sequence of tokens that can be parsed as a datum, 1) returns Ok(Some(..)) 2) advances the stream to the first token that is not part of the sequence. If the stream does not start with tokens that can be parsed as a datum:
- Return Ok(None) if
rest_of_stream
has not been advanced. - Returns Err(..) otherwise.