Remove associated_consts crate feature
Rewrite has_associated_consts probe to better represent internal usage Update README
This commit is contained in:
parent
6190ecb861
commit
981d2bf32d
|
@ -22,4 +22,3 @@ features = ["std"]
|
||||||
default = ["std"]
|
default = ["std"]
|
||||||
std = []
|
std = []
|
||||||
i128 = []
|
i128 = []
|
||||||
associated_consts = []
|
|
||||||
|
|
|
@ -42,9 +42,8 @@ Implementations for `i128` and `u128` are only available with Rust 1.26 and
|
||||||
later. The build script automatically detects this, but you can make it
|
later. The build script automatically detects this, but you can make it
|
||||||
mandatory by enabling the `i128` crate feature.
|
mandatory by enabling the `i128` crate feature.
|
||||||
|
|
||||||
Similarly, additional traits making use of associated constants are available
|
Traits making use of associated constants are available with Rust 1.22 and
|
||||||
with Rust 1.22 and later. Again, the build script automatically detects this,
|
later. This is automatically detected by the build script.
|
||||||
but you can make it mandatory by enabling the `associated_consts` crate feature.
|
|
||||||
|
|
||||||
## Releases
|
## Releases
|
||||||
|
|
||||||
|
|
12
build.rs
12
build.rs
|
@ -9,14 +9,16 @@ fn main() {
|
||||||
panic!("i128 support was not detected!");
|
panic!("i128 support was not detected!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Verbose probe to ensure we can blanket impl associated const traits.
|
||||||
|
// Early versions of associated consts prohibited this due to a restriction
|
||||||
|
// of const expressions to non-Drop types.
|
||||||
if probe("fn main() {
|
if probe("fn main() {
|
||||||
struct TestDrop(); impl Drop for TestDrop { fn drop(&mut self) {} }
|
trait Const { const CONST: Self; }
|
||||||
trait TestConst { const TEST: Self; }
|
impl<T: Const> Const for Option<T> {
|
||||||
impl TestConst for TestDrop { const TEST: TestDrop = TestDrop(); }
|
const CONST: Option<T> = Some(T::CONST);
|
||||||
|
}
|
||||||
}") {
|
}") {
|
||||||
println!("cargo:rustc-cfg=has_associated_consts");
|
println!("cargo:rustc-cfg=has_associated_consts");
|
||||||
} else if env::var_os("CARGO_FEATURE_ASSOCIATED_CONSTS").is_some() {
|
|
||||||
panic!("associated constant support was not detected!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue