diff --git a/godot-core/src/obj/traits.rs b/godot-core/src/obj/traits.rs index 0888efc89..5c05bf39f 100644 --- a/godot-core/src/obj/traits.rs +++ b/godot-core/src/obj/traits.rs @@ -210,6 +210,24 @@ pub trait IndexEnum: EngineEnum { /// Trait that's implemented for user-defined classes that provide a `Base` field. /// /// Gives direct access to the containing `Gd` from `Self`. +/// +/// # Using WithBaseField as a bound +/// +/// In order to call `self.base()` or `self.base_mut()` within a trait or on a type you define, the type of `Self::Base` must be specified via `WithBaseField` +/// +/// E.g. +/// +/// ```no_run +/// # use godot::prelude::*; +/// # use godot::obj::WithBaseField; +/// fn some_fn(value: &T) +/// where +/// T: WithBaseField, +/// { +/// let base = value.base(); +/// } +/// ``` +/// // Possible alternative for builder APIs, although even less ergonomic: Base could be Base and return Gd. #[diagnostic::on_unimplemented( message = "Class `{Self}` requires a `Base` field",