Revise docs for system set marker traits (#7882)
# Objective #7863 introduced a potential footgun. When trying to incorrectly add a user-defined type using `in_base_set`, the compiler will suggest that the user implement `BaseSystemSet` for their type. This is a reasonable-sounding suggestion, however this is not the correct way to make a base set, and will lead to a confusing panic message when a marker trait is implemented for the wrong type. ## Solution Rewrite the documentation for these traits, making it more clear that `BaseSystemSet` is a marker for types that are already base sets, and not a way to define a base set.
This commit is contained in:
parent
73c1ab1d42
commit
85c8fb9dfa
@ -37,14 +37,18 @@ pub trait SystemSet: DynHash + Debug + Send + Sync + 'static {
|
||||
fn dyn_clone(&self) -> Box<dyn SystemSet>;
|
||||
}
|
||||
|
||||
/// A system set that is never contained in another set.
|
||||
/// Systems and other system sets may only belong to one base set.
|
||||
/// A marker trait for `SystemSet` types where [`is_base`] returns `true`.
|
||||
/// This should only be implemented for types that satisfy this requirement.
|
||||
/// It is automatically implemented for base set types by `#[derive(SystemSet)]`.
|
||||
///
|
||||
/// This should only be implemented for types that return `true` from [`SystemSet::is_base`].
|
||||
/// [`is_base`]: SystemSet::is_base
|
||||
pub trait BaseSystemSet: SystemSet {}
|
||||
|
||||
/// System sets that are *not* base sets. This should not be implemented for
|
||||
/// any types that implement [`BaseSystemSet`].
|
||||
/// A marker trait for `SystemSet` types where [`is_base`] returns `false`.
|
||||
/// This should only be implemented for types that satisfy this requirement.
|
||||
/// It is automatically implemented for non-base set types by `#[derive(SystemSet)]`.
|
||||
///
|
||||
/// [`is_base`]: SystemSet::is_base
|
||||
pub trait FreeSystemSet: SystemSet {}
|
||||
|
||||
impl PartialEq for dyn SystemSet {
|
||||
|
Loading…
Reference in New Issue
Block a user