dimforge / dimforge/nalgebra

Can't implement Index for Vector3 but works for Point3 since 0.13

Open
#319 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

I just upgraded my nalgebra 0.12 codebase to 0.14 and noticed that starting with 0.13 my build starts failing with this error:

> error[E0210]: type parameter `>::Buffer` must be used as the type parameter for some local type (e.g. `MyStruct`); only traits defined in the current crate can be implemented for a type parameter

I have this:

```rust
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum Axis {
/// Index of the X axis.
X = 0,

/// Index of the Y axis.
Y = 1,

/// Index of the Z axis.
Z = 2,
}

// This works:
impl Index for Point3 {
type Output = f32;

fn index(&self, axis: Axis) -> &f32 {
match axis {
Axis::X => &self.x,
Axis::Y => &self.y,
Axis::Z => &self.z,
}
}
}

// This now fails but used to work:
impl Index for Vector3 {
type Output = f32;

fn index(&self, axis: Axis) -> &f32 {
match axis {
Axis::X => &self.x,
Axis::Y => &self.y,
Axis::Z => &self.z,
}
}
}
```

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.