You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Trait that's implemented for user-defined classes that provide a `Base<T>` field.
211
211
///
212
212
/// Gives direct access to the containing `Gd<Self>` from `Self`.
213
+
///
214
+
/// # Using WithBaseField as a bound
215
+
///
216
+
/// 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<Base = T>`
217
+
///
218
+
/// E.g.
219
+
///
220
+
/// ```no_run
221
+
/// # use godot::prelude::*;
222
+
/// # use godot::obj::WithBaseField;
223
+
/// fn some_fn<T>(value: &T)
224
+
/// where
225
+
/// T: WithBaseField<Base = Node3D>,
226
+
/// {
227
+
/// let base = value.base();
228
+
/// }
229
+
/// ```
230
+
///
213
231
// Possible alternative for builder APIs, although even less ergonomic: Base<T> could be Base<T, Self> and return Gd<Self>.
214
232
#[diagnostic::on_unimplemented(
215
233
message = "Class `{Self}` requires a `Base<T>` field",
0 commit comments