rust-num / num-complex

Complex numbers for Rust
Apache License 2.0
232 stars 50 forks source link

const complex new #48

Closed burrbull closed 5 years ago

burrbull commented 5 years ago

Is it possible to specify rust version feature gate?

cuviper commented 5 years ago

You can use emit_rustc_version in the build script to get a cfg flag. The entire fn would have to be duplicated with and without the const qualifier.

However, do we really need const fn new? The fields are public, so Complex { re, im } should work just fine in constant expressions. (I suppose that could also argue against having new at all...)

cuviper commented 5 years ago

I added conditional const functions in https://github.com/rust-num/num-rational/pull/48, if that helps you here.

burrbull commented 5 years ago

Does not work:

error[E0592]: duplicate definitions with name `new`

Accidentally close PR.

burrbull commented 5 years ago

Sorry. All fine.

Created new #63