I am trying to write an API server that uses RegexSet
. Here is the code that uses it.
fn main() {
let path_regex = regex::RegexSet = regex::RegexSet::new(&[
r"^/api/$",
...
r"^/logs/$",
r"^/logs/(?P<logpath>[^/?#]*)$",
r"^/version/$"
]).unwrap();
}
The slice passed to RegexSet
has 346 elements. When I run this, I get
error[E0277]: `&[&str; 346]` is not an iterator
--> src/server/mod.rs:650:60
|
650 | pub static ref GLOBAL_REGEX_SET: regex::RegexSet = regex::RegexSet::new(&[
| ^^^^^^^^^^^^^^^^^^^^ `&[&str; 346]` is not an iterator
|
= help: the trait `std::iter::Iterator` is not implemented for `&[&str; 346]`
= note: required because of the requirements on the impl of `std::iter::IntoIterator` for `&[&str; 346]`
= note: required by `server::paths::regex::RegexSet::new`
Looking at the documentation, IntoIterator
has only been implemented for arrays of size up to 32
I tried to implement that trait, resulting in the error
error[E0119]: conflicting implementations of trait `std::iter::IntoIterator` for type `&[_; 346]`:
--> src/server/mod.rs:651:5
|
651 | impl<'a, T> IntoIterator for &'a [T; 346] {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: conflicting implementation in crate `core`:
- impl<I> std::iter::IntoIterator for I
where I: std::iter::Iterator;
= note: upstream crates may add new impl of trait `std::iter::Iterator` for type `&[_; 346]` in future versions
How do I work around this?