我正在尝试编写使用RegexSet
的API服务器。这是使用它的代码。
fn main() {
let path_regex = regex::RegexSet = regex::RegexSet::new(&[
r"^/api/$",
...
r"^/logs/$",
r"^/logs/(?P<logpath>[^/?#]*)$",
r"^/version/$"
]).unwrap();
}
传递给RegexSet
的切片具有346个元素。当我运行它时,我得到
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`
查看文档,IntoIterator
仅dropna()
我试图实现该特征,导致错误
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
我该如何解决?