- Here is the code. It compiles:
use combine_language::LanguageEnv;
use combine::stream::easy;
use combine::choice;
#[test]
fn test_00() {
let env: LanguageEnv<easy::Stream<&str>> = unimplemented!();
let rops = "1 2 3 4 5 6 7 8"
.split_whitespace()
.map(|s: &str| env.reserved_op(s))
.collect::<Vec<_>>();
let a = env.reserved_op("a");
let b = env.reserved_op("b");
let t = choice([a, b]);
// this fails to compile
// let t1 = choice(&[a, b]);
// let t2 = choice(rops);
// let t3 = choice(rops.as_slice());
}
- I need to figure out how to make either t2 or t3 compile.
t2:
|
23 | let t2 = choice(rops);
| ^^^^^^ the trait `combine::parser::choice::ChoiceParser` is not implemented for `std::vec::Vec<combine_language::Lex<'_, '_, combine_language::Reserved<'_, '_, combine::stream::easy::Stream<&str>>>>`
|
= note: required by `combine::parser::choice::choice`
error: aborting due to previous error
t3:
|
24 | let t3 = choice(rops.as_slice());
| ^^^^^^ the trait `combine::parser::choice::ChoiceParser` is not implemented for `&[combine_language::Lex<'_, '_, combine_language::Reserved<'_, '_, combine::stream::easy::Stream<&str>>>]`
|
= help: the following implementations were found:
<[P; 15] as combine::parser::choice::ChoiceParser>
<[P; 1] as combine::parser::choice::ChoiceParser>
<[P; 21] as combine::parser::choice::ChoiceParser>
<[P; 31] as combine::parser::choice::ChoiceParser>
and 30 others
= note: required by `combine::parser::choice::choice`
error: aborting due to previous error
this is surprising as the docs, combine::parser::choice::choice - Rust , claims it works on "a slice or an array"
Thanks!i