-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't declare static fns in multiple anonymous implementations #4228
Comments
Not critical for 0.6 (and possibly a wontfix but I haven't read carefully enough); de-milestoning. |
I think we're not going to support this. |
@catamorphism said I could reopen this. It's not a priority, but I feel it'd be handy. |
Use case: two constructors for |
This would be useful for impl<T: Trignometric> Cmplx<T> {
fn from_polar(r: T, arg: T) -> Cmplx<T> { .. }
fn to_polar(&self) -> (T,T) { .. }
} rather than needlessly requiring all types used with |
yeah I hit this too: https://gist.github.com/bjz/7ccf949e65e361863cd2 :( Use case: impl<T> Vec4<T> {
#[inline(always)]
fn new(x: T, y: T, z: T, w: T) -> Vec4<T> {
Vec4 { x: x, y: y, z: z, w: w }
}
#[inline(always)]
fn len() -> uint { 4 }
//...
}
impl<T:Copy + Num> Vec4<T> {
#[inline(always)]
fn identity() -> Vec4<T> {
Vec4::new(One::one::<T>(), One::one::<T>(), One::one::<T>(), One::one::<T>())
}
#[inline(always)]
fn zero() -> Vec4<T> {
Vec4::new(Zero::zero::<T>(), Zero::zero::<T>(), Zero::zero::<T>(), Zero::zero::<T>())
}
//...
} Specifically because I would like to be able to to return a Vec4 (like in GLSL) for component-wise vector comparisons. |
Fixed by #7029 |
Some static functions may only make sense for certain constrained typarams, but this is disallowed. For example:
However, rust errors with this message:
The text was updated successfully, but these errors were encountered: