Consider implementing From<TupleOfLengthN> for VectorN
- Dominant language
- Rust
- Stars
- 4.8k
- Forks
- 565
- PR merge metrics
- No merged PRs in 30d
Description
**Problem space**:
I recently noticed that the following compiles:
```rust
Vector3::::from([1.0, 1.0, 1.0]);
```
while in contrast this does not:
```rust
Vector3::::from((1.0, 1.0, 1.0));
```
For the some reason or other, a user may store float data in a tuple at some point.
**Current workarounds**:
Converting a tuple of size `N` to a `VectorN` is still possible by taking the constituent parts.
```rust
let pt = (1.0, 1.0, 1.0);
let (x, y, z) = pt;
let p: Vector3 = Vector3::new(x, y, z);
```
Or more directly:
```rust
let pt = (1.0, 1.0, 1.0);
let p: Vector3 = Vector3::new(pt.0, pt.1, pt.2);
```
**Proposed solution**:
For ergonomics, implementing `From` for tuples of the same length as a vector could be desirable.
**Further questions**:
While `impl From<(f32,f32,f32)> for Vector3` may make sense, the question of whether tuples where the size is greater than 6 is worth considering (but tuples of particularly long length are probably an irregular case).
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.