diff --git a/fish-rust/src/builtins/status.rs b/fish-rust/src/builtins/status.rs index ed56e7f95..750b86ec8 100644 --- a/fish-rust/src/builtins/status.rs +++ b/fish-rust/src/builtins/status.rs @@ -180,10 +180,10 @@ const LONG_OPTIONS: &[woption] = &[ fn print_features(streams: &mut io_streams_t) { // TODO: move this to features.rs let mut max_len = i32::MIN; - for md in &features::METADATA { + for md in features::METADATA { max_len = max_len.max(md.name.len() as i32); } - for md in &features::METADATA { + for md in features::METADATA { let set = if feature_test(md.flag) { L!("on") } else { @@ -433,7 +433,7 @@ pub fn status( } use TestFeatureRetVal::*; let mut retval = Some(TEST_FEATURE_NOT_RECOGNIZED as c_int); - for md in &features::METADATA { + for md in features::METADATA { if md.name == args[0] { retval = match feature_test(md.flag) { true => Some(TEST_FEATURE_ON as c_int), diff --git a/fish-rust/src/future_feature_flags.rs b/fish-rust/src/future_feature_flags.rs index f2e4cdf5f..601ee663d 100644 --- a/fish-rust/src/future_feature_flags.rs +++ b/fish-rust/src/future_feature_flags.rs @@ -71,7 +71,7 @@ pub struct FeatureMetadata { /// The metadata, indexed by flag. #[widestrs] -pub const METADATA: [FeatureMetadata; 4] = [ +pub const METADATA: &[FeatureMetadata] = &[ FeatureMetadata { flag: FeatureFlag::stderr_nocaret, name: "stderr-nocaret"L, @@ -114,12 +114,11 @@ pub fn test(flag: FeatureFlag) -> bool { FEATURES.test(flag) } -pub fn feature_test(flag: FeatureFlag) -> bool { - test(flag) -} +pub use test as feature_test; /// Set a flag. -pub fn set(flag: FeatureFlag, value: bool) { +#[cfg(any(test, feature = "fish-ffi-tests"))] +pub(self) fn set(flag: FeatureFlag, value: bool) { FEATURES.set(flag, value); } @@ -182,7 +181,7 @@ impl Features { self.set(md.flag, value); } } else { - for md in &METADATA { + for md in METADATA { if md.groups == name || name == "all"L { if !md.read_only { self.set(md.flag, value); @@ -205,7 +204,7 @@ fn test_feature_flags() { // Ensure every metadata is represented once. let mut counts: [usize; METADATA.len()] = [0; METADATA.len()]; - for md in &METADATA { + for md in METADATA { counts[md.flag.repr as usize] += 1; } for count in counts {