Reduce feature gates.

This commit is contained in:
Stephen Chung
2021-12-06 20:52:47 +08:00
parent 5b64e0b383
commit 2a7a648429
17 changed files with 176 additions and 253 deletions

View File

@@ -25,15 +25,9 @@ use std::{
#[cfg(not(feature = "no_float"))]
use std::str::FromStr;
#[cfg(not(feature = "no_float"))]
use crate::FLOAT;
#[cfg(not(feature = "no_float"))]
use num_traits::Float;
#[cfg(not(feature = "no_index"))]
use crate::Array;
/// A type representing the access mode of a function.
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
pub enum FnAccess {
@@ -1918,7 +1912,7 @@ impl FnCallExpr {
pub struct FloatWrapper<F>(F);
#[cfg(not(feature = "no_float"))]
impl Hash for FloatWrapper<FLOAT> {
impl Hash for FloatWrapper<crate::FLOAT> {
#[inline(always)]
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.0.to_ne_bytes().hash(state);
@@ -2022,11 +2016,11 @@ impl<F: Float> FloatWrapper<F> {
}
#[cfg(not(feature = "no_float"))]
impl FloatWrapper<FLOAT> {
impl FloatWrapper<crate::FLOAT> {
/// Create a new [`FloatWrapper`].
#[inline(always)]
#[must_use]
pub const fn new_const(value: FLOAT) -> Self {
pub const fn new_const(value: crate::FLOAT) -> Self {
Self(value)
}
}
@@ -2037,7 +2031,7 @@ impl FloatWrapper<FLOAT> {
pub enum Expr {
/// Dynamic constant.
///
/// Used to hold complex constants such as [`Array`] or [`Map`][crate::Map] for quick cloning.
/// Used to hold complex constants such as [`Array`][crate::Array] or [`Map`][crate::Map] for quick cloning.
/// Primitive data types should use the appropriate variants to avoid an allocation.
DynamicConstant(Box<Dynamic>, Position),
/// Boolean constant.
@@ -2048,7 +2042,7 @@ pub enum Expr {
///
/// Not available under `no_float`.
#[cfg(not(feature = "no_float"))]
FloatConstant(FloatWrapper<FLOAT>, Position),
FloatConstant(FloatWrapper<crate::FLOAT>, Position),
/// Character constant.
CharConstant(char, Position),
/// [String][ImmutableString] constant.
@@ -2224,7 +2218,7 @@ impl Expr {
#[cfg(not(feature = "no_index"))]
Self::Array(x, _) if self.is_constant() => {
let mut arr = Array::with_capacity(x.len());
let mut arr = crate::Array::with_capacity(x.len());
arr.extend(
x.iter()
.map(|v| v.get_literal_value().expect("constant value")),