-
Notifications
You must be signed in to change notification settings - Fork 51
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
type alias #21
Comments
For comparison, see pub type N32 = NoisyFloat<f32, NumChecker>;
pub type N64 = NoisyFloat<f64, NumChecker>;
pub type R32 = NoisyFloat<f32, FiniteChecker>;
pub type R64 = NoisyFloat<f64, FiniteChecker>;
pub fn n32(value: f32) -> N32 { N32::new(value) }
pub fn n64(value: f64) -> N64 { N64::new(value) }
pub fn r32(value: f32) -> R32 { R32::new(value) }
pub fn r64(value: f64) -> R64 { R64::new(value) } (Docs stripped and reformatted for vertical space by me) So pub fn c32(re: f32, im: f32) -> Complex32;
pub fn c64(re: f64, im: f64) -> Complex64; And then you'd just be able to write |
If we were to add short aliases, I would want to at least conform to convention as However, since import renaming is possible, I'm inclined to leave it as-is. Even using your own private type alias would still be completely compatible with all other uses of I see a little more value in having
You shouldn't need the This won't quite work though, because the literals pub fn c64<T: Into<f64>>(re: T, im: T) -> Complex64 {
Complex64::new(re.into(), im.into())
} And perhaps also something like: pub fn to_c64<T: ToPrimitive>(re: &T, im: &T) -> Option<Complex64> {
if let Some(re) = re.to_f64() {
if let Some(im) = im.to_f64() {
return Some(c64(re, im));
}
}
None
} |
Consider to remove:
in favor of:
It might seem controversial, but:
u64 i64 f64 c64
,c64::new(1.0,2.0)
is a already a pain compared to1+2i
,Another reason is that rustc could start to lint against
because of a non camel case type. It would be an ergonomic disaster if one needs to turn that off explicitly.
The text was updated successfully, but these errors were encountered: