Skip to content

Commit

Permalink
Merge pull request #110 from light-curve/const-doc-method
Browse files Browse the repository at this point in the history
Make doc() static methods constant
  • Loading branch information
hombit authored Aug 31, 2023
2 parents cddac9c + 611a0d8 commit d28c218
Show file tree
Hide file tree
Showing 44 changed files with 48 additions and 47 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- **Build breaking** Minimum supported Rust version (MSRV) 1.57 -> 1.65 (released 2022-11-03)
- Feature's `doc()` static method is `const` now

### Deprecated

Expand Down
2 changes: 1 addition & 1 deletion src/extractor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ where
}

impl<T, F> FeatureExtractor<T, F> {
pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/amplitude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl Amplitude {
Self {}
}

pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/anderson_darling_normal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl AndersonDarlingNormal {
Self {}
}

pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/bazin_fit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl BazinFit {
BazinInitsBounds::Default
}

pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/beyond_n_std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ where
}

impl<T> BeyondNStd<T> {
pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/bins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ where
T: Float,
F: FeatureEvaluator<T>,
{
pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}

Expand Down
2 changes: 1 addition & 1 deletion src/features/cusum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl Cusum {
Self {}
}

pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/duration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl Duration {
Self {}
}

pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/eta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl Eta {
Self {}
}

pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/eta_e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl EtaE {
Self {}
}

pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/excess_variance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl ExcessVariance {
Self {}
}

pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/inter_percentile_range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl InterPercentileRange {
0.25
}

pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/kurtosis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl Kurtosis {
Self {}
}

pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/linear_fit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl LinearFit {
Self {}
}

pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/linear_trend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl LinearTrend {
Self {}
}

pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/magnitude_percentage_ratio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl MagnitudePercentageRatio {
0.05
}

pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/maximum_slope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl MaximumSlope {
Self {}
}

pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/maximum_time_interval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl MaximumTimeInterval {
Self {}
}

pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/mean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl Mean {
Self {}
}

pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/mean_variance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl MeanVariance {
Self {}
}

pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/median.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl Median {
Self {}
}

pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/median_absolute_deviation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl MedianAbsoluteDeviation {
Self {}
}

pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/median_buffer_range_percentage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ where
}

impl<T> MedianBufferRangePercentage<T> {
pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/minimum_time_interval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl MinimumTimeInterval {
Self {}
}

pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/observation_count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl ObservationCount {
Self {}
}

pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/otsu_split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl OtsuSplit {
Self {}
}

pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}

Expand Down
2 changes: 1 addition & 1 deletion src/features/percent_amplitude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl PercentAmplitude {
Self {}
}

pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/percent_difference_magnitude_percentile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl PercentDifferenceMagnitudePercentile {
0.05
}

pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/features/periodogram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl PeriodogramPeaks {
1
}

pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
PERIODOGRAM_PEAK_DOC
}
}
Expand Down Expand Up @@ -347,7 +347,7 @@ impl<T, F> Periodogram<T, F>
where
T: Float,
{
pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/reduced_chi2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl ReducedChi2 {
Self {}
}

pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/skew.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl Skew {
Self {}
}

pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/standard_deviation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl StandardDeviation {
Self {}
}

pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/stetson_k.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl StetsonK {
Self {}
}

pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/time_mean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl TimeMean {
Self {}
}

pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/time_standard_deviation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl TimeStandardDeviation {
Self {}
}

pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/transformed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ where
})
}

pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC!()
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/villar_fit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl VillarFit {
VillarInitsBounds::Default
}

pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}

Expand Down
2 changes: 1 addition & 1 deletion src/features/weighted_mean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl WeightedMean {
Self {}
}

pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,10 @@ macro_rules! check_doc_static_method {
($name: ident, $feature: ty) => {
#[test]
fn $name() {
let doc = <$feature>::doc();
assert!(doc.contains("Depends on: "));
assert!(doc.contains("Minimum number of observations: "));
assert!(doc.contains("Number of features: "));
const DOC: &'static str = <$feature>::doc();
assert!(DOC.contains("Depends on: "));
assert!(DOC.contains("Minimum number of observations: "));
assert!(DOC.contains("Number of features: "));
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/transformers/bazin_fit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ where
8.9_f32.value_into().unwrap()
}

pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/transformers/clipped_lg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ where
f64::MIN_POSITIVE.log10().approx().unwrap()
}

pub fn doc() -> &'static str {
pub const fn doc() -> &'static str {
DOC
}

Expand Down
Loading

0 comments on commit d28c218

Please sign in to comment.