pub trait Nightly {
// Required methods
fn emit_unstable_feature(
&self,
feature: UnstableFeature,
allowed_features: &AllowedFeatures,
) -> bool;
fn emit_unstable_feature_bundle<F: IntoIterator<Item = UnstableFeature>>(
&self,
features: F,
allowed_features: &AllowedFeatures,
bundle_name: &str,
) -> bool;
}Expand description
Required Methods§
Sourcefn emit_unstable_feature(
&self,
feature: UnstableFeature,
allowed_features: &AllowedFeatures,
) -> bool
fn emit_unstable_feature( &self, feature: UnstableFeature, allowed_features: &AllowedFeatures, ) -> bool
Offers at least 2 cfg flags for all known features
§Feature enablement: cfg(unstable_...)
- To be used at top-level crate via
#![cfg_attr(unstable_foo, feature(foo))]
§Cfg-gating: cfg(has_...)
- Do not rely on
#[cfg(not(unstable_foo))]to suggest thatfeature(foo)is stable! - There are 3 reasons that
#[cfg(unstable_foo)]could befalse:- The build is using
stable/betaor the feature is not on theallow-featureswhitelist - The feature has been stabilised
- The compiler is from before the feature was implemented
- The build is using
- All known features have a
#[cfg(has_...)]for this purpose.
§Note
- You must pass a set of AllowedFeatures, created by calling cargo_allowed_features
- If you need to test that a feature is available in order to cfg-gate your code and it is not on the list of known features, please raise a PR with a suggested probe.
- Returns
trueifhas_...has been set. This meansOtherFeaturewill always returnfalse
Sourcefn emit_unstable_feature_bundle<F: IntoIterator<Item = UnstableFeature>>(
&self,
features: F,
allowed_features: &AllowedFeatures,
bundle_name: &str,
) -> bool
fn emit_unstable_feature_bundle<F: IntoIterator<Item = UnstableFeature>>( &self, features: F, allowed_features: &AllowedFeatures, bundle_name: &str, ) -> bool
Calls emit_unstable_feature for all given features,
additionally setting has_{bundlename} & returning true if all features are available.
§Note
- This will always return false if any of the features are
OtherFeature
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".