dimforge / dimforge/nalgebra

Error with impl Iterator

Open
#594 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
4.8k
Forks
565
PR merge metrics
No merged PRs in 30d

Description

Hello! I'm trying to create a function that takes an array of vectors and returns an iterator of pairs of that vectors. But I'm keep getting an error when I try to do it with impl Iterator.

This code produces an error:
```
// nalgebra = "0.18.0"
use nalgebra;

type Vec2 = nalgebra::Vector2;
fn foo(data: &Vec) -> impl Iterator {
data.iter().zip(data.iter().skip(1))
}
```

```
error[E0271]: type mismatch resolving `>>, std::iter::Skip>>>> as std::iter::Iterator>::Item == (&nalgebra::base::matrix::Matrix>::Buffer>, &nalgebra::base::matrix::Matrix>::Buffer>)`
--> src/main.rs:4:29
|
4 | fn foo(data: &Vec) -> impl Iterator {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `nalgebra::base::array_storage::ArrayStorage`, found associated type
|
= note: expected type `(&nalgebra::base::matrix::Matrix>, &nalgebra::base::matrix::Matrix>)`
found type `(&nalgebra::base::matrix::Matrix>::Buffer>, &nalgebra::base::matrix::Matrix>::Buffer>)`
= note: the return type of a function must have a statically known size
```

Turns out even the simplest code produces a similar error:
```
use nalgebra;

type Vec2 = nalgebra::Vector2;
fn foo(data: &Vec) -> impl Iterator {
data.iter()
}
```

```
error[E0271]: type mismatch resolving `>> as std::iter::Iterator>::Item == &nalgebra::base::matrix::Matrix>::Buffer>`
--> src/main.rs:4:29
|
4 | fn foo(data: &Vec) -> impl Iterator {
| ^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `nalgebra::base::array_storage::ArrayStorage`, found associated type
|
= note: expected type `&nalgebra::base::matrix::Matrix>`
found type `&nalgebra::base::matrix::Matrix>::Buffer>`
= note: the return type of a function must have a statically known size
```

Should it be possible to create an iterator of vectors from Vec?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.